I hope one of you smart people out there can help me with what seems like a real simple questing but I can't quite figure out.
In a script I am doing a cmp on two files. I am trying to check the exit status with an if statement but can't seem to figure out the syntax. If the exit status is 1 I want to do something else something else. I am using Solaris 8 and my shell is ksh.
Hi,
As far as I know any unix command returns a return code. Depending on the shell you use the check may slightly differ.
If you are using ksh - The following should work
....your command here....
rtrncd=$?
if [ $rtrncd -ne 0 ]
then
echo problems # problem happened
exit $rtrncd # exit with the same bad return code
fi
# no problems happened - Continue with your scrip
....possibly more code here....