#!/bin/sh # @(#)clipr.flt.sh 1.2 11/8/94 . lmpaths PROGNAME=$0 if [ "$CLPRDEBUG" ] then PROGNAME=`basename $PROGNAME` debugmsg () { echo `date '+%H:%M:%S %d %b %y'`: $PROGNAME: "$*" >>/tmp/${CLIPR_CMD_NAME}.out } else debugmsg () { : } fi if [ $# != 6 ] then echo $0: filter invoked with bad arguments 1>&2 debugmsg "filter invoked with bad arguments" exit 1 fi CLISPOOL=$1 CLIENT=$2 JOBNAME=$3 CLSHARE=$4 Printer=$5 Options=$6 FILE=$CLIPRDIR_PATH/$Printer/$JOBNAME debugmsg FILE is $FILE ECODE=0 # Null out the printjob file on exit trap 'debugmsg exit with "$ECODE" FILE=$FILE ; >$FILE ; exit "$ECODE"' 0 trap 'ECODE=1; debugmsg caught signal; exit' 1 2 15 # sanity check if [ ! -x "$CLISPOOL" ] then debugmsg "Problem with $CLISPOOL" exit 2 fi # close stdout, and re-open. Our parent (the interface # script) will wait for us to finish, and then do a write to the stdout # (either a trailing formfeed, or a "cancelled" message. # Currently we share file pointers with our parent, so any output to stdout # that we do also increments their file offset. If we don't close # and reopen, then their trailing write goes out where they think the end of # the file is. We want the file to be as short as possible when we're all # done, especially in the case of a cancellation. In that case, the host # half (this script) dies, but has no way of killing PRINT on the client # machine. If the file is artificially long, then at best PRINT will spend # a long time sending NULLs (from the hole in the file) to the printer, and # at worst, will still be printing the next time we are invoked, and will # start dumping the next job to the printer, starting somewhere in the middle. # # Also, if the standard int'fc script changes, and for some reason we aren't # the last filter in the pipe, we for sure want to make ourselves the last one. exec >&- # if the Options list does not contain stty=raw, then set the CLICAT to ud # expr, like strcmp(), returns inverted error codes (0 == false) debugmsg "Options are :$Options:" if expr "$Options" : '.*stty=raw.*' >$DEV_NULL_PATH || expr "$Options" : '.*stty=-opost.*' >$DEV_NULL_PATH then : # then don't do anything -- we're pretty raw by nature else CLICAT="$UD_PATH -dz" debugmsg "stty raw not found, CLICAT is $CLICAT" # if the Options list does contain stty=tab3, or it seems that # the standard interface script would have set stty tab3, because the # printer doesn't have tabs or they're not 8 cols apart, then we must # expand tabs ourselves. We can't exaclty expect their stty command # to affect us! # set defaults : ${TERMINFO:=/usr/lib/terminfo} : ${TERM:=unknown} if expr "$Options" : '.*stty=tab3.*' >$DEV_NULL_PATH || # user set stty=tab3 [ "8" != "`tput it 2>$DEV_NULL_PATH`" ] # spacing not at 8 then # then do the equivalent of "stty tab3" CLICAT="newform -i-8 | ${CLICAT}" debugmsg "stty tab3 found, CLICAT is $CLICAT" fi fi debugmsg "CLICAT is :$CLICAT:" # send stdin to $FILE, using cat by default eval ${CLICAT:=cat} 2>$DEV_NULL_PATH >>$FILE || { debugmsg "Problem catting in $0" $NETEVENT_PATH -e admin -s SPOOLER \ -t "Problem creating job file for client printing. Increase the maximum file size kernel parameter." ECODE=1 exit 1 } # Submit the job to the client's print queue. # Clipr produces tracing output on stdout. Redirect it # to /tmp/something for debugging purposes. Stderr has messages for # the administrator in case of problems. Stderr has already been redirected by # the standard model script to the lp.tell program, which will in turn # give it to the Spooler for use in an administrative alert. debugmsg "executing $CLISPOOL $CLIENT $CLSHARE $JOBNAME" if [ "$CLPRDEBUG" ] then $CLISPOOL $CLIENT $CLSHARE $JOBNAME >>/tmp/${CLIPR_CMD_NAME}.out else $CLISPOOL $CLIENT $CLSHARE $JOBNAME >$DEV_NULL_PATH fi ECODE=$? if [ $ECODE != 0 ] then $LPDISABLE_PATH -W -r"disabled due to client error" $Printer fi debugmsg "ECODE is $ECODE" exit $ECODE