in reply to UNIX shell scripts + pipes

In Bourne Shell (only 3 programs, but that's cuz I'm lazy):
#!/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
Or, if the intermediate file names don't matter, and the intermediate files aren't too big:
#!/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
That answers your original question. That having been said, the answers given above are much better ideas. This way does give you a couple of break points so that if prog4.pl chokes, you still have the output from prog3.pl and a place to start debugging prog4.pl

Hope this helps, thor