Backend Proxy Shell Script

alex at j2anywhere.com alex at j2anywhere.com
Fri Oct 29 17:17:15 PDT 2004


I have the following shell script. When I print to the printer attached to that backend I experience problem I have tracked the problem down to the forwarding of my stdin stream into the parallel backend.

Could you please guide me how to forward the print job correctly to the parallel backend.

#!/bin/bash
LOG=/tmp/cupsproxyfilter.log
echo "=======================================================" >> $LOG
date >> $LOG
echo "=======================================================" >> $LOG
echo "I am running under this user ID:" >> $LOG
id >> $LOG
echo "=======================================================" >> $LOG
env >> $LOG

echo "TEMP FILES" >> $LOG
ls -a /var/spool/cups/tmp/ >> $LOG
echo PAGECOUNT : $PGCOUNT >> $LOG
echo 0 $0 >> $LOG
echo 1 $1 >> $LOG
echo 2 $2 >> $LOG
echo 3 $3 >> $LOG
echo 4 $4 >> $LOG
echo 5 $5 >> $LOG
echo 6 $6 >> $LOG

# create a directory to store the output of each single filter
# under a uniq name for later debugging purpose
[ -d /tmp/cups-filter-outputs ] || mkdir /tmp/cups-filter-outputs

# in case of wrong number of arguments: print usage hint
if test "$#" -eq "0"; then
	echo direct "\"Audited Parallel\" \"AUDITED Canon S400\" \"Audited Parallel Port\""
	exit 0
fi

if test "$#" -lt "5"; then
	echo "ERROR: Number of arguments ($#) is wrong" 1>&2
	echo "USAGE: `basename $0` job-id user title copies options [file]" 1>&2
	exit 1
fi

if test "$#" -gt "6"; then
	echo "ERROR: Number of arguments ($#) is wrong" 1>&2
	echo "USAGE: `basename $0` job-id user title copies options [file]" 1>&2
	exit 1
fi

if test "$#" -eq "5"; then
	INPUT="-"
else
	INPUT="$6"
fi

echo "Complete invocation command" >> $LOG
echo $0 "$@" >> $LOG
echo "$#" >> $LOG
echo `id` >> $LOG
MESSAGE=`echo Print JOB $1 Submitted by : $2 with Title : $3`
export DISPLAY=localhost:0
/usr/X11R6/bin/xmessage $MESSAGE
echo "Calling parallel" "$@" >> $LOG
cat - > /tmp/printjob.out
#cat /tmp/printjob.out | /usr/lib/cups/backend/parallel "$@"
exec parallel "$@" < /tmp/printjob.out





More information about the cups mailing list