Exit status in the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exit status in the script
# 1  
Old 01-07-2016
Exit status in the script

Hi all,

I am trying to use a script (a.sh) which is calling another script(b.sh).
And I want to use the exit code(set by me) of b.sh in a.sh.
I am using this in b.sh
Code:
  
#!/bin/sh
<-- code -->
if [ "${ScriptStatus}" = "Ended_Successfully" ] ; then
        
        
                   exit 0
    else
            exit 1
    fi

But now my problem is that when b.sh is getting the exit 0 or exit 1, it is making the a.sh to exit too.
My understanding is that exit command in b.sh should only make b.sh to stop but it is making a.sh to stop too.
If not, Could you help me in achieving this by another method.

Thanks
# 2  
Old 01-07-2016
What are you trying to achieve?

Is this code a.sh or b.sh?
Code:
#!/bin/sh
<-- code -->
if [ "${ScriptStatus}" = "Ended_Successfully" ] ; then    
    exit 0
else
    exit 1
fi

Regardless of which script this is (a or b), this will only affect the status exit of this script.
Please, post both scripts and a clear message of what you are trying to achieve.
# 3  
Old 01-07-2016
In addition to what Aia said, please also tell us what operating system you're using. (The behavior of /bin/sh varies from system to system.)

Note also that showing us the following:
Code:
<-- code -->

instead of the actual code in your script leaves a LOT of things hidden that can materially affect the operation of both a.sh and b.sh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inner script run and its exit status

Main Script #!/bin/ksh echo "Maimn script" ./clocal/www/web-data/WAS/WebSphere7/scripts/DealerLocator/Scripts/secondscript.ksh echo "$? = status" Sdecond Script #!/bin/ksh echo "In second SCript" exit 1 Output: Maimn script ./testmain.ksh:... (4 Replies)
Discussion started by: dineshaila
4 Replies

2. Shell Programming and Scripting

Exit status of the ksh Script

Hi Im trying to write a script that will archive some file using java program.Below is the part of the script that I use and my problem is that the script always return with status 0.Below is part of my script(end part) purge.ksh echo "No of files before tar :... (4 Replies)
Discussion started by: saachinsiva
4 Replies

3. Shell Programming and Scripting

exit status from the script is always 0

Hi , I have a bash script , which does the network configuration. Messages from this script are dumped on console as well as stored in a log file . This script is invoked from a C code using system call . The script returns different exit code , to indicate different error cases. The... (1 Reply)
Discussion started by: abhirai
1 Replies

4. Shell Programming and Scripting

How to test for the ssh exit status in script?

Hello; I regularly run monitoring scripts over ssh to monitoring scripts But whenever a server is hung or in maintenance mode, my script hangs.. Are there anyways to trap exit status and be on my way ?? Looked at the ssh manpage and all I can see is a "-q" option for quiet mode .. Thank... (2 Replies)
Discussion started by: delphys
2 Replies

5. Shell Programming and Scripting

Need urgent help on exit status of the script

Guys, I am writing a script that executes a series of commands with a function like: _Command "ps -ef | grep java" _Command "vmstat" _Command "llll" Even if one of these commands fail, my script should exit with non-zero code i.e 16. If all commands are successful, my script should exit... (7 Replies)
Discussion started by: sriramperumalla
7 Replies

6. Shell Programming and Scripting

HELP WITH .ksh script converting the exit status

Hi Can someone help me please? In a standard UNIX .ksh script, if you have the exit status..say 5...what line do you have to enter into the script for this number to be automatically converted to its actual exit reason by looking up the exit status file...wherever that is? thanks angus (1 Reply)
Discussion started by: angusyoung
1 Replies

7. Shell Programming and Scripting

check exit status - Expect Script

from my main script, i am calling an expect script. there are a lot of conditions in the Expect script and it can have any exit value based on success or failure of the Expect Script. how can i check the exit status of Expect scritp in the main script. (1 Reply)
Discussion started by: iamcool
1 Replies

8. UNIX for Dummies Questions & Answers

how to check exit status in awk script

Hi, I have a main program which have below lines - awk -f test.awk inputFileName - I wonder how to check status return from awk script. content of awk script: test.awk --- if ( pass validation ) { exit 1 } else { (1 Reply)
Discussion started by: epall
1 Replies

9. Shell Programming and Scripting

checking exit status of a shell script

Hi, I have tried with the following code; if ;then echo "Failure." else echo "Success." fi to test the exit status of the test.ksh shell script. But whatever is the exit status of the test.ksh shell script Failure. is always printed. Please help. regards, Dipankar. (2 Replies)
Discussion started by: kdipankar
2 Replies

10. Shell Programming and Scripting

CronTab script exit status 134

Hi All, I have one shell script through which I am executing some datastage and quality jobs(these are ETL Jobs), when I run the script through unix prompt then the script is executing fine and getting desired results. But when I schedule the same script in crontab then in the middle of the... (3 Replies)
Discussion started by: VijayKumar
3 Replies
Login or Register to Ask a Question