return to first page linux journal archive
keywordscontents

Listing 4. Filter for Postscript of TIFF File on HP

#!/bin/sh
# filter script for text, Postscript or
# TIFF printing on an HP Deskjet
LOG=/var/spool/lpd/hp/filter.log
cat - > /tmp/hp.in
FTYPE="`file /tmp/hp.in`"
if [ -n "`echo $FTYPE | grep text`" ]
then
   awk '{printf "%s\r\n",$0}' /tmp/hp.in
elif [ -n "`echo $FTYPE | grep -i postscript`" ]
then
   gs -sDEVICE=cdj550 -q -sOutputFile=- \
   /tmp/hp.in
elif [ -n "`echo $FTYPE | grep TIFF`" ]
then
   tiff2ps -ap /tmp/hp.in | gs -sDEVICE=cdj550 \
   -q -OutputFile=-
else
   echo "Unknown file type, $FTYPE" \
   | tee -a $LOG | \
   Mail -s 'cannot print' markp
fi