Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex shell script, need expert help 1

Status
Not open for further replies.

schu

MIS
Jun 21, 2001
188
HK
I have a "big job" script which I need to run several instances over several servers. Each script returns an integer where > 0 means error.
What I need to do is to check the status of the returned code to see if it has failed. Here is what i am trying to do.

for rhost in `cat server list`
do
if [ $rhost == "`hostname`" ]
then
# Its local
/tmp/bigjob.sh &
else
# It's remote
rcp /tmp/bigjob.sh ${rhost}:/tmp/bigjob.sh
rsh $RHOST /tmp/bigjob.sh &
fi
done

# wait for background jobs to complete
wait

The problem is how do I find out which one succeeds and which job failed.

thx, in advance
 
Once you find out whether the file is local
or not, use a conditional statement... This
will at least notify you by e-mail which
jobs failed.

if [ "file local" ]; then

(/tmp/bigjob.sh ;
if [ "$? != "0" ] ; then
/usr/bin/mail &quot;your username&quot; <<EOF
${rhost} job failed.
EOF
fi) &

else

&quot;remote test&quot;
use same idea from above

fi


------------
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top