![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare two dates using Shell Programming | dave_nithis | Shell Programming and Scripting | 4 | 01-04-2008 05:18 AM |
| how to compare text value in shell | reply2soumya | UNIX for Advanced & Expert Users | 2 | 06-19-2007 01:03 PM |
| How to recognize that the server is currently unavailable? | munna_dude | High Level Programming | 2 | 03-10-2007 12:16 AM |
| How to compare the dates in shell script | vaji | Shell Programming and Scripting | 9 | 02-28-2007 12:34 AM |
| Doesn't recognize the mv command | zoolz | Shell Programming and Scripting | 2 | 11-14-2005 10:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
shell script cant recognize if else compare
hi
I face the problem the if else statement dint return correct result for me my script as below: #!/bin/ksh sqlplus -s /nolog <<EOF connect databaseuser/password column num new_value num format 9999 set head off select count(*) num from table1; exit num EOF if [ $? -gt 10 ]; then echo "$?" else echo "stop" fi ----- How I know $? is integer? Is it because both is not integer so cant go the compare?? Any one please help , Thanks and regards, Jase |
|
||||
|
What are you actually trying to compare with 10? If it is the output of the query i.e. (count(*) ) that you are trying to compare with 10 then you can use the following code.
#!/bin/ksh RESULT=`sqlplus -s /nolog <<EOF connect databaseuser/password set head off select count(*) from table1; EOF` if [ $RESULT -gt 10 ]; then echo $RESULT else echo "stop" fi |
|
||||
|
Thanks for your reply
Yes, I need to compare the result from the query, if the count(*) > 10 then some action I need to take...but it seem like the result is not integer..so it cant be compare with number.. got any way to convert it to integer.. sowjanya.addala I had try this before but the RESULT cant go to proceed the sql statement inside. The value of the RESULT is just capture the SQL statement not the output query. any way appreciate your help. regards, Jase Last edited by jaseloh; 12-05-2005 at 08:46 PM.. |
|
||||
|
look at this
#!/bin/ksh RESULT=`sqlplus -s /nolog <<EOF connect databaseuser/password set head off spool log; select count(*) from table1; EOF` RESULT=`head log.lst` if [ $RESULT -gt 10 ]; then echo $RESULT else echo "stop" fi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|