Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
>> In bash you can check the last program's return code using the
>> variable $?. In tcsh, you can use $status.
>
> Would this be something Mark could use?
Depends. In a lot of my scripts, I do something like the following:
###BEGIN###
#!/bin/bash
cmd1 | cmd2 | grep SOMETHING >/dev/null 2>&1
if [ $? == 0 ] ; then
echo found SOMETHING
exitcode=0
else
if [ $? == 1 ] ; then
echo did not find SOMETHING
exitcode=1
fi
fi
exit $exitcode
###END###
Hopefully this will format correctly.
This pipes commands together (cmd1 > cmd2 > grep), suppressing output.
The return code of the final command (in this case, grep) is checked
and preserved and an appropriate message is printed out. Finally, the
program exits with the last command's exit value. Bash's value
checking has to be nested because it's strictly if/then/else, not
if/then/else if/else. Kind of ugly, but it works.
This is something I use all the time, but this isn't a real example -
you'd have to build on it.
ryan woodsmall
EMAIL:PROTECTED
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members