#! /bin/sh # # pagecount - gets page count from a AppleTalk/PostScript printer # # Rex Sanders, US Geological Survey, December 7, 1993 # US Government work in the public domain # # CAPBIN is the directory of the CAP command "lwpr" CAPBIN=/usr/local/cap/bin if [ $# -lt 1 ] then echo "usage: $0 PrinterName:LaserWriter@ZoneName [delay]" echo " PrinterName... is the full AppleTalk name of the printer" echo " delay is the optional wait time, default 10 seconds" exit 3 fi trap 'rm -f /tmp/pagecount1.$$ /tmp/pagecount2.$$; exit 2' 1 2 15 echo "statusdict begin pagecount end = flush" > /tmp/pagecount1.$$ $CAPBIN/lwpr -p "$1" /tmp/pagecount1.$$ > /tmp/pagecount2.$$ & pid=$! sleep ${2-10} if grep '^[0-9][0-9]*$' /tmp/pagecount2.$$ then rm -f /tmp/pagecount1.$$ /tmp/pagecount2.$$ else # # Printer busy or not responding... # echo 0 rm -f /tmp/pagecount1.$$ /tmp/pagecount2.$$ kill $pid > /dev/null 2>&1 exit 1 fi