#!/bin/sh -x FILE1=$1 FILE2=$2 FILE3=$3 FILE4=$4 prog1.pl $FILE1 $FILE2 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog1.pl: $STATUS" exit $STATUS fi prog2.pl $FILE2 $FILE3 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog2.pl: $STATUS" exit $STATUS fi prog3.pl $FILE3 $FILE4 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog3.pl: $STATUS" exit $STATUS fi #### #!/bin/sh FILE1=$1 FILE2=/tmp/file.$$.1 FILE3=/tmp/file.$$.2 FILE4=$2 SAFE=/path/to/save_file.$$ prog1.pl $FILE1 $FILE2 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog1.pl: $STATUS" exit $STATUS fi prog2.pl $FILE2 $FILE3 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog2.pl: $STATUS" mv $FILE2 $SAVE exit $STATUS fi prog3.pl $FILE3 $FILE4 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Belch in prog3.pl: $STATUS" mv $FILE3 $SAVE exit $STATUS fi #Clean-up temp files /bin/rm -f $FILE1 $FILE2 STATUS=$? if [ $STATUS != 0 =; then set +x echo "Error removing temporary files" echo "$FILE1 and" echo "$FILE2." echo "Please clean-up by hand" exit $STATUS fi