How to get the exit status of a command in nner script to the outer script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get the exit status of a command in nner script to the outer script?
# 1  
Old 02-08-2013
How to get the exit status of a command in nner script to the outer script?

Hi all,

I have a shell script inside which i am executing another shell script. In the inner script im executing a command. i want the status of that command in the outer script to perform some validations.

How to get its status please help!!1

Im using ksh.
# 2  
Old 02-08-2013
You'd have to give better example. Most likely the inner script returns the status of the last executed command. If the command of interest is not the last executed command, than you would store it ret=$? and make sure you exit "$ret".
# 3  
Old 02-08-2013
try using the exit $NUMBER statement inside the inner script which upon return to the outer script will bring in the value of that particular variable. if that is not acceptable, try exporting it to environment using export , 3rd option would be use a temp file with the value of the parameter and then use it by reading the temp file.

Last edited by busyboy; 02-08-2013 at 08:45 AM.. Reason: return is only for functions , scripts return their exit status..is that right?
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 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 #!/bin/sh <-- code --> if ; then exit 0 else exit 1 fiBut... (2 Replies)
Discussion started by: Raj999
2 Replies

3. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

4. 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

5. 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

6. Shell Programming and Scripting

store last command exit status in variable in shell script

Hello All My req is to store the exit status of a command in shell variable I want to check whether the file has header or not The header will contain the string DATA_ACQ_CYC_CNTL_ID So I am running the command head -1 $i | grep DATA_ACQ_CYC_CNTL_ID Now I have to check if... (6 Replies)
Discussion started by: Pratik4891
6 Replies

7. 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

8. Shell Programming and Scripting

problem in exit status of the command in a shell script-FTP

Hi All, I have developed below script for FTP a file from unix machine to another machine. ftpToABC () { USER='xyz' PASSWD='abc' echo "open xx.yy.zbx.aaa user $USER $PASSWD binary echo "put $1 abc.txt" >> /home/tmp/ftp.$$ echo "quit" >> /home/tmp/ftp.$$ ftp -ivn <... (3 Replies)
Discussion started by: RSC1985
3 Replies

9. 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

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