#!/bin/sh # contributed: Mathieu Braem & Peter De Wachter # Error codes # # Key Value Meaning # JSUCC 0 Successful # JFAIL 1, 32 Failed - retry later # JABORT 2, 33 Abort - terminate queue processing # JREMOVE 3, 34 Failed - remove job # JHOLD 6, 37 Failed - hold this job # Other Abort - terminate queue processing T=`mktemp -t mb-print.XXXXXX` || exit 3 cat > $T while [ "$1" != "" ]; do case "$1" in -C*) tmp=$1 class=${tmp#-C};; -d*) tmp=$1 spooldir=${tmp#-d};; -j*) tmp=$1 job=${tmp#-j};; -n*) tmp=$1 ruser="${tmp#-n}";; -h*) tmp=$1 rhost="${tmp#-h}";; esac shift done host=`grep -a ^remotehost= "$spooldir/hf$class$job" | sed -e 's/.*=//'` # no sanity checking necessary on host: if host is a nonsense value or # the empty string, user will also be the empty string (note that # there are no two consecutive spaces in the log file) user=`grep " $host " /var/log/natlogins | tail -1 | cut -d " " -f 3` # and if user is empty, the IG print system will not accept the job # Do substitutions cat $T | \ sed "s/^P.*/P$user/" | \ sed "s/^H.*/P$host/" rm -rf $T exit 0