If download time doesn't matter, you'll find a good example for such a
shell script in the Unix port of PMX available from the GMD music archive
(I can't remember the precise path, but Werner Icking will be able to
provide that). That package contains a shell script named 'pmx' which does
exactly what you want except it runs PMX and MusiXTeX rather than OpusTeX.
However, you shoud be able to edit it for your purposes (that's easier
than writing a script from scratch anyway). Said PMX script stops when
any of the passes fails and it cleans up most of the temporary files.
HTH,
Schtepf.
************************************************************
** We fat all creatures else to fat us, and we fat **
** ourselves for maggots. Your fat King and your lean **
** beggar, is but variable service, two dishes but to **
** one table; that's the end. **
************************************************************
** HomeBrew Entertainment **
** http://www.mathematik.uni-stuttgart.de/~evert/ **
** [update pending] **
**--------------------------------------------------------**
** [EMAIL PROTECTED] (Stefan Evert) **
************************************************************