Not returning from a sub script?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Not returning from a sub script?
# 1  
Old 01-23-2014
Not returning from a sub script?

My problem in brief is that I execute a script from another script and I can not pick up the return code from that script, or otherwise I am not returning from that script. I have an echo in the executed script and we get a response code of 0 and exit that script with the return code. I then try to assign the return code to a variable SCHEDULER_EXIT in the executing script and echo that to a file. I never get to the echo, so the script ends on the assign of the return code to the variable SCHEDULER_EXIT, or it never gets there.

exec /udd026/SAS_Progs/ $SCHEDULER_ARGS >> /udd001/app/TWS/logs/TWS_MRun.log 
 echo IVEREX62 $STAB `date`  has ended scheduler exit ${SCHEDULER_EXIT} >> /udd001/app/TWS/logs/TWS_MRun.log

any ideas?
# 2  
Old 01-23-2014
Hi, you are using exec, so the shell executing /udd026/SAS_Progs/ will replace the parent script's shell, without creating a new process. So this code:
 echo IVEREX62 $STAB `date`  has ended scheduler exit ${SCHEDULER_EXIT} >> /udd001/app/TWS/logs/TWS_MRun.log

will never get executed. Try leaving out exec

BTW: there should not be any spaces around the assignment operator (=):

Last edited by Scrutinizer; 01-24-2014 at 03:05 PM..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script not returning what I am expecting

Hi there I am trying to create a script where I am checking the process is being run by the correct user, when I go to run the script it is not returning what I am expecting and I am not 100% sure why!!! First off I have determined what the process user should be at the top of the script ... (3 Replies)
Discussion started by: simpsa27
3 Replies

2. Shell Programming and Scripting

Child exiting and not returning to parent script

I am having a parent scripts which reads a file with child scripts name. I need to read one by one child script , execute it and 1. If child script fails send mail to the team with the log file 2. If the child script executes fine then proceed with the next child script execution. #!... (3 Replies)
Discussion started by: nw2unx123
3 Replies

3. Shell Programming and Scripting

Script returning 0

hello i write a script which calculate free space but he always is 0 thats wrong with my script? getFileSystemPerformanceData() { if ; then if grep -q "Ubuntu" /etc/issue ; then CMD="df -lP | grep -v "\/home" | grep -v "\/dev/mapper/VolGroup-lv_root"" elif grep... (5 Replies)
Discussion started by: donatas1234
5 Replies

4. Shell Programming and Scripting

Returning to shell from previous script

Found myself stuck on this seemingly trivial issue. I have this script which call other shell files to do their deeds. The shell files in turn call some other programs as well. My problem is that in two of these shell files, the control doesnt return to next command in script unless the Enter key... (2 Replies)
Discussion started by: DoesntMatter
2 Replies

5. Shell Programming and Scripting

Script returning null results

Hi, The following shell script returning null results could you please tell me whats the problem in script, ********************************* #!/bin/ksh . $HOME/conf/systemProperties/ a=`date +"%y%m%d"` set -x for i in `cat... (2 Replies)
Discussion started by: shivanete
2 Replies

6. UNIX for Advanced & Expert Users

Returning a value to a calling script

Hi. I'm trying to call a script named from within my main script named In I want to set a value to the variable fileExist, but then I want to reference the value in the script. Whenever I attempt this the echo statement is just blank. ... (5 Replies)
Discussion started by: buechler66
5 Replies

7. AIX

The shell script is not returning proper result

Can anybody pls look into this script and tell me where I went wrong. After running this script, it is showing like "Trying to overlay current working directory ABORT!!!" :-( ARGCNT=$# if then echo "Two parameters are needed for this shell " echo "Please try again with... (1 Reply)
Discussion started by: clnsharma123
1 Replies

8. Shell Programming and Scripting

returning to the parent shell after invoking a script within a script

Hi everybody, I have a script in which I'm invoking another script which runs in a subshell. after the script is executed I want to return to the parent shell as some variables are set. However i'm unable to return to my original shell as the script which i'm calling inside is invoked in... (5 Replies)
Discussion started by: gurukottur
5 Replies

9. Shell Programming and Scripting

Returning to begining of a script

Dear all, When i ask a question in my script if the answer is not correct i need to goback to the begning of the script and ask the question again. ex - What is your name ? saman Name is not correct ...try again What is the name ? Nimal Thank you.... (2 Replies)
Discussion started by: Nayanajith
2 Replies

10. Shell Programming and Scripting

Returning Values (shell Script)

I have an application on Informix 4GL, and I am invoking the shell script from the program, but I need to know if the shell script work fine or not, in order to continue the process. I know that we can use $? to get the final status but this is on unix command. How can I return a value from the... (3 Replies)
Discussion started by: jennifer01
3 Replies
Login or Register to Ask a Question