![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem In Shell Script | satyakide | Shell Programming and Scripting | 11 | 09-24-2007 10:00 AM |
| Help! Problem with Shell Script. | pektl | Shell Programming and Scripting | 7 | 05-29-2006 05:08 AM |
| Problem with SU or SSH in shell script | sravanp | UNIX for Dummies Questions & Answers | 2 | 01-24-2006 12:00 PM |
| Shell Script problem | bnohifi | Shell Programming and Scripting | 1 | 07-07-2005 02:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell script problem
Hi,
I have a shell script in which I am calling a function from a different shell script. This functions executes the SQL and the results are stored in a log file. If the result of the SQL is "no rows selected" then I need to exit the main shell script. My shell script is executing fine if the records are found. But I am unable to stop or exit the shell script if there are no records found. I tried using the following step.. but it is not working. echo $SQL_REPORT | grep 'no' >> /dev/null if [ $? = 0 ] then echo "== Found" >> $LOGFILE_SCRIPT else echo "== Not Found" >> $LOGFILE_SCRIPT fi I am able to find it if I 'm using the following code. VAR=`grep 'no' $SQL_REPORT | sed -e "s/ //g;s/[ ]*$//" | cut -c1-14` if [ $VAR = 'norowsselected' ] then exit fi But u can't always expect the result as "no rows selected". Hope I have made it clear. Thanks Shash |
|
||||
|
But is there any way I can totally come out of the main script.
This exit is only coming out of the function and the loop in which the main shell script was calling the function. I need to stop the main script at this point of time. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|