The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Terminal And Cron Job Return Different Status Code isaac_ho Shell Programming and Scripting 1 06-02-2008 12:12 AM
Return of EXIT status ( $? ) ZINGARO HP-UX 1 03-12-2008 07:07 AM
Verify scp return status new2ss Shell Programming and Scripting 2 06-28-2006 10:04 PM
Return status of all previous runs mpang_ Shell Programming and Scripting 4 06-27-2006 02:58 AM
return ftp status blt123 Shell Programming and Scripting 12 07-21-2005 05:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-28-2002
Shaz Shaz is offline
Registered User
  
 

Join Date: May 2002
Posts: 23
Exclamation Return status...

Hello there!
Here is my problem. I hope I can get some help about it.
I need to know how can I get the return code of an application in the Unix shell script.

The script is like below:

PREVIOUS STATEMENT & VARIABLES

sqlplus scott/tiger @$sqldir/$sqlscript

NEXT STATEMENT (Like status=$?)

If for some reason sqlplus (Oracle client application for making a connection to Oracle or run a PL/SQL script against Oracle)
craps out, script will stop running, but, It does not return to the next statement after sqlplus... I've already tried "$?" to capture the return code but as I said the next statement after sqlplus never be reached....

I run the script using nohup on a AIX machine.

Thanks.
  #2 (permalink)  
Old 10-28-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
"craps out" doesn't tell us very much.

If the program terminates, either because it explicitly decided to invoke the exit() system call or because of the default action of signal delivered to the process by the kernel, then control will pass to the next statement in your script and you may obtain the exit code.

On the other hand, if the process continues to run, then there is no exit code. A running process is a running process. You cannot get an exit code until a process exits.
  #3 (permalink)  
Old 10-29-2002
Shaz Shaz is offline
Registered User
  
 

Join Date: May 2002
Posts: 23
Thanks for your answer.

I guess I need to put it this way. Assume I am running the Test.sh which is a Unix script and in the middle of Test.sh I call the sqlplus and the sqlplus successfully runs one script that has "exit" command which is the exit command for sqlplus and reaches the "exit" command and terminates the sqlplus. (I guess here is exit with return code zero otherwise I would see sqlplus prompt) but still doesn't get back to the Test.sh because my next statement after sqlplus is just a simple below code:
echo "Test.sh done!" > Test.sh.log
But this line never been executed.

I am a novice in Unix world. If I get disappointed, I get back to AS/400... I guess who cares...

Thanks a lot.
  #4 (permalink)  
Old 10-31-2002
itsupplies itsupplies is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 23
Without seeing the script, its hard to see what is going wrong!!.. Can you do 2 things.

1 Post the script.
2 Post the output of the following command : ksh -x scriptname

where scriptname is your script!!

John
  #5 (permalink)  
Old 10-31-2002
photh photh is offline
Registered User
  
 

Join Date: Oct 2002
Location: NC
Posts: 4
Try this:

RETURN=`sqlplus -s $USER <<END
select <column> from <table_name>;
quit
END`
if [ -z "$RETURN" ]; then
echo "Error - No rows returned "
exit 0
else
printf "Good return"
fi


Depends on what you're trying to do.
  #6 (permalink)  
Old 11-04-2002
Shaz Shaz is offline
Registered User
  
 

Join Date: May 2002
Posts: 23
Hi,
Hrere is the script:
#########################################
#!/bin/sh

sqlplus $CONNECT_STRING @$SCRIPTDIR/$PLSQL_SCRPIT

status=$?
if [ $status -ne 0 ]
then
echo "Error in $SCRIPTDIR/$PLSQL_SCRPIT " > $LOGFILE
echo `date` >> $LOGFILE
exit 10010
else
echo "$PLSQL_SCRIPT finished successfully. " > $LOGFILE
echo `date` >> $LOGFILE
exit 0
fi
#########################################
After sqlplus execution it doesn't reach the status=$? statement.

Thanks a lot for your help.
  #7 (permalink)  
Old 11-05-2002
krishnamarajuc krishnamarajuc is offline
Registered User
  
 

Join Date: Oct 2002
Location: J.P.Nagar,Bangalore, India
Posts: 11
Shell prog

I feel it is better to run child shell, so that once the child shell terminates, we can get the status of the shell which, in turn, returns the status of the command,....


Please repost if youneed any suggestions or research in UNIX, C,C++ and networking or kernel prog or embedded or system level....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0