Return status...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Return status...
# 1  
Old 10-28-2002
Error 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.
Smilie
# 2  
Old 10-28-2002
"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  
Old 10-29-2002
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.
Smilie
# 4  
Old 10-31-2002
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  
Old 10-31-2002
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  
Old 11-04-2002
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  
Old 11-05-2002
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....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return Status

Hi can you explain me, what does variables $@ and $* return and how are they used, if can give me a sample example it could be helpful. Thanks in advance, Regards, Abhishek S. (1 Reply)
Discussion started by: abhisheksunkari
1 Replies

2. UNIX for Dummies Questions & Answers

opposite return status in c shell

there is something wrong with my system. when I do this: diff file1 file1 && echo 1 the output is 1. but diff file1 file2 >/dev/null && echo 1 output nothing while diff file1 file2 >/dev/null || echo 1 shows 1. the same with "grep" return status. they are both GNU utilities.... (5 Replies)
Discussion started by: phil518
5 Replies

3. Shell Programming and Scripting

checking for return status between multiple commands

i have to run set of commands command1 command2 command3 command4 Now Whenever any of these command fails i should quit while capturing error message. Is there a better way then checking for $? after each command. (1 Reply)
Discussion started by: vickylife
1 Replies

4. Shell Programming and Scripting

capturing C++ binary return status in perl

Hello, I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue. Can you please help me on this. Thanks, Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies

5. Shell Programming and Scripting

capturing C++ binary return status in perl

Hello, I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue. Can you please help me on this. Thanks, Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies

6. Shell Programming and Scripting

evaluate return status of a function

Hi all I'm trying to evalute the return status of a function without much success. I've put a very basic example below to explain. check_ok() works fine but when used within an if statement, it always returns true, whether it is true or false. I'm guessing it returns true as the function... (4 Replies)
Discussion started by: tig2810
4 Replies

7. HP-UX

Return of EXIT status ( $? )

I have the question: How return the exit code from then assign : VAR=$(command ) for ex. VAR=$(ls ....) VAREXIT=$? echo $VAREXIT VAREXIT is equal to 0 if the directory exist or not exist. WHI?? if i execute the command direct from line-command , the value of $? is different if... (1 Reply)
Discussion started by: ZINGARO
1 Replies

8. Shell Programming and Scripting

Verify scp return status

Hi all below is a snippet of my perl codesystem ("scp -pq $dest_file $path");How i can i trap the return status? ie if the scp fails how can i know ? (2 Replies)
Discussion started by: new2ss
2 Replies

9. Shell Programming and Scripting

Return status of all previous runs

hi, I set the crontab to execute script A every 5 minutes from 9:00 am to 4:00 pm everyday, now at 12:00am I want to run another script if and only if all the previous runs of script A return OK, can anyone tell me how it could be done? thank you very very much! (4 Replies)
Discussion started by: mpang_
4 Replies

10. Shell Programming and Scripting

return ftp status

Hello, I still have problems when trying to figure out if the status of an ftp was successful. I ftp to different types (nt, vax, unix, etc...) of machines. I am trying to write a universal script that will ftp a file and then check to see if the ftp was successful. I have tried the... (12 Replies)
Discussion started by: blt123
12 Replies
Login or Register to Ask a Question