#!/bin/sh set -e CMDLINE="$0 $@" RawPrintFile="-- unset -- (false)" NColumns="-- unset --" NLines="-- unset --" Login="-- unset --" Indent="-- unset -- (8)" Host="-- unset --" JobName="-- unset --" while [ $# -gt 0 ];do case $1 in -c ) RawPrintFile=true shift;; -w* ) NColumns=${1#-w} shift;; -l* ) NLines=${1#-l} shift;; -n ) Login=$2 shift;shift;; -i* ) Indent=${1#-i} shift;; -h ) Host=$2 shift;shift;; -j ) JobName=$2 shift;shift;; * ) echo PrintFilter unknow option >&2 exit 1 ;; esac done echo 3 TXTNAME=$(tempfile -p prtf- -s .txt) TMPNAME=${TXTNAME%.txt} Header="$(dd bs=512 count=4|mimencode)" ftype=$(echo "$Header"|mimencode -u|file -b -|tr A-Z a-z) case $ftype in *postscript* ) fname=$TMPNAME.ps ;; *hp* ) fname=$TMPNAME.plt ;; *ascii* ) fname=$TMPNAME.ascii ;; *gif* ) fname=$TMPNAME.gif ;; *jpeg* ) fname=$TMPNAME.jpg ;; *tiff* ) fname=$TMPNAME.tif ;; * ) fname=$TMPNAME.job ;; esac tempfile -n $fname ( echo "$Header"|mimencode -u; cat - ) >$fname ( # Write accross text file echo "%% Header file for $fname" echo "PrintFile : $fname" echo "ReqDate : $(date)" echo "User : $USER" echo "Printer : ${PWD##*/}" echo "CommandeLine : $CMDLINE" echo "RawPrintFile : $RawPrintFile" echo "NColumns : $NColumns" echo "NLines : $NLines" echo "Login : $Login" echo "Indent : $Indent" echo "Host : $Host" echo "JobName : $JobName" echo "=======================================" # set ) >$SPOOLDIR/$TXTNAME