From: Green, Simon (Simon.Green@EU.ALTRIA.COM)
Date: Mon Apr 26 2004 - 06:09:02 EDT
If you want to get a little bit fancy, you can use the logic functions in
Korn shell.
e.g.
function1
if [[ $? -ne 0 ]]
then
let "err_flag = err_flag | 1"
fi
function2
if [[ $? -ne 0 ]]
then
let "err_flag = err_flag | 2"
fi
So if the result is 2 or 3, function1 failed; if it's 1 or 3 function2
failed.
To test it...
let "f1_failed = err_flag & 1"
if [[ $f1_failed -ne 0 ]]
then
echo "Function 1 failed one or more times."
fi
let "f2_failed = err_flag & 2"
if [[ $f2_failed -ne 0 ]]
then
echo "Function 2 failed one or more times."
fi
This gives you a bit more flexibility, in case you want it.
The logical stuff is quite handy to know, anyway. It can save on having
hoards of different control switches. (But mostly it's just neat, in a
geeky sort of way. :-))
See the "System User's Guide: Operating System and Devices", chapter 11, for
details.
-- Simon Green Altria ITSC Europe Ltd AIX-L Archive at https://new-lists.princeton.edu/listserv/aix-l.html New to AIX? http://publib-b.boulder.ibm.com/redbooks.nsf/portals/UNIX N.B. Unsolicited email from vendors will not be appreciated. Please post all follow-ups to the list. > -----Original Message----- > From: Bob.Kelley@BRINKSINC.COM [mailto:Bob.Kelley@BRINKSINC.COM] > Sent: 23 April 2004 17:02 > To: aix-l@Princeton.EDU > Subject: graceful script exit > > > If I have a script with does a number of things like tars, > copy commands, > etc. What is the best way to generate a flag if a SINGLE > command in the > script fails? In other words, if I'm thinking about this > correctly, I want > to get a page when the script is finished, and one command > didn't finish > correctly, even if some of the commands have succeeded.
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:51 EDT