#!/bin/sh -f # # Option processing first OPTSTR="n:h:" args= while getopts $OPTSTR opt ; do case $opt in n ) LPUSER="$OPTARG" ;; # user name h ) LPHOST="$OPTARG" ;; # originating host esac done shift `expr $OPTIND - 1` cat - > /tmp/scratch1/tex$PPID.tex # Then we figure out where we are. DIR=$PWD # Then we move to a working directory cd /tmp/scratch1 # Then we run LaTeX on the file. If the compile fails, # we send the log file to the user and give up. jlatex \\batchmode\\input tex$PPID.tex >/dev/null 2>&1 || { cat /etc/lpdadmin/texerr1 tex$PPID.log | sendmail -oi $LPUSER; echo "BARF"; exit 0; } # # If it went okay, we check whether there were bibliographies if test "`grep -c "There were undefined references" tex$PPID.log`" != "0" ; then bibtex tex$PPID >/dev/null 2>&1 if test "`grep -c "error message.*)" tex$PPID.blg`" != "0" ; then cat /etc/lpdadmin/biberr tex$PPID.blg | sendmail -oi $LPUSER echo "BARF" exit 0 fi jlatex \\batchmode\\input tex$PPID.tex >/dev/null 2>&1 || { cat /etc/lpdadmin/texerr2 tex$PPID.log | sendmail -oi $LPUSER; echo "BARF"; exit 0; } jlatex \\batchmode\\input tex$PPID.tex >/dev/null 2>&1 || { cat /etc/lpdadmin/texerr3 tex$PPID.log | sendmail -oi $LPUSER; echo "BARF"; exit 0; } else # # Alternatively, we check whether there were labels and # cross-references. if test "`grep -c "Rerun to get cross-references right" tex$PPID.log`" != "0" ; then jlatex \\batchmode\\input tex$PPID.tex >/dev/null 2>&1 || { cat /etc/lpdadmin/texerr4 tex$PPID.log | sendmail -oi $LPUSER; echo "BARF"; exit 0; } fi fi # # If all's been done without error, we throw the DVI file # through standard output and hope for the best! cat tex$PPID.dvi rm -f tex$PPID.*