%> cat mycmd
#!/bin/csh -f
exit 0;
%> cat wrapper.csh
#!/bin/csh -f
mycmd
if ($status) then
echo "error executing mycmd"
exit 1
endif
echo "successful execution of mycmd"
%>
But there is another easier way if you don't care about the actual value of the exit status.
%> cat easier_wrapper.csh
#!/bin/csh -f
if ! { mycmd } then
echo "error executing mycmd"
exit 1
endif
echo "successful execution of mycmd"
%>
Notice the use of curly braces around mycmd.
2 comments:
Even after 4 years I leave this simple tip handy :)
The entrance strategy is actually more important than the exit strategy. See the link below for more info.
#exit
www.ufgop.org
Post a Comment