Focal Point
[SOLVED]How to call a unix shell script in processs flow,capture script exit status

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/5397096386

September 02, 2016, 02:40 PM
Rajesh T
[SOLVED]How to call a unix shell script in processs flow,capture script exit status
Hi

I have to run a Unix script from Data Migrator and capture the exit status of the execution of the script.

I tried solution provided in below old post

How to call a unix shell script in the process flow?

-SET &MYRETURN=SYSTEM(100,'ksh test.ksh,'D10');
-TYPE MYRETURN : &MYRETURN.

The &MYRETURN is always '0' even if script fails.

Is there a way to capture the exit code from Unix Script

Thanks

This message has been edited. Last edited by: Tamra,
September 06, 2016, 12:51 PM
dhagen
Example that uses echo to post a return code:

-* Create and execute a bash script command

-* preset the ruturn file with bad values
EX -LINES * EDAPUT TXT,bshrc,C,FILE
999
EDAPUT*
-RUN

-* build the script file
EX -LINES * EDAPUT TXT,bshscript,C,FILE
#!/usr/bin/ksh
touch /root/test 2> /dev/null
if [ $? -eq 0 ]
then
  echo 000 > bshrc.txt
  exit 0
else
  echo 001 > bshrc.txt
  exit 1
fi
EDAPUT*
-RUN
-* change script to executable
! chmod +x bshscript.txt
! ./bshscript.txt
-RUN

-* evaluate our returncode
-TYPE Showing bshrc
FILEDEF RTNCODE DISK bshrc.txt
-RUN
-READ RTNCODE &BSHRETURN.I3.
-TYPE Our Return Code: &BSHRETURN
-RUN  



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott