File backend to replace existing pin printers

Calvin Gordon calvin.gordon at sasktel.net
Fri Sep 19 14:26:07 PDT 2008


> Nothing there says it found and loaded it, only that it is able to
> construct the name that the backend should have.
>
> If /usr/lib/cups/backend/filewrite actually exists and is executable,
> the next thing to check is that the first line (#!...) points to
> something that exists.  Bash in particular reports "No such file or
> directory" with no indication that it's the #! line that is wrong (and
> also reports it if the problem is that the program indicated isn't
> executable or various other failure modes).

Making progress.  Was bothered by that request for my user ID auth, so rebooted the machine, saved the old filewrite to a backup, and retyped it using nano in case it was corrupted because i copied it from a windows machine using notepad originally.

I now get the 3 files created where we want them, both logs, and a zero byte test.prn.

1. filewite.log
finishings=3 number-up=1 job-uuid=urn:uuid:5815b191-6e99-3e2c-5fea-afb3e36f29a3
49
lp
(stdin)
1
finishings=3 number-up=1 job-uuid=urn:uuid:5815b191-6e99-3e2c-5fea-afb3e36f29a3

2. fw.errlog
lpstat: Unknown destination "/home/profit-master/test.prn"!
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
cat: finishings=3: No such file or directory
cat: number-up=1: No such file or directory
cat: job-uuid=urn:uuid:5815b191-6e99-3e2c-5fea-afb3e36f29a3: No such file or directory

3. my new bare bones filewrite
#!/bin/bash
exec >>/home/profit-master/fw.errlog 2>&1
FILE=$5 || FILE="-";
LOG=/home/profit-master/filewrite.log; export LOG ;
JOBID=$1 ;
USER=$2 ;
TITLE=$3 ;
COPIES=$4 ;
OPTIONS=$5 ;
PID=$$ ;
echo ${FILE}    >> ${LOG} ;
echo ${JOBID}  	>> ${LOG} ;
echo ${USER}   	>> ${LOG} ;
echo ${TITLE}  	>> ${LOG} ;
echo ${COPIES} 	>> ${LOG} ;
echo ${OPTIONS} >> ${LOG} ;
if [ $# -eq 0 ]; then
  echo "what's up doc ?"
  exit 0
fi
if [ $# -ne 5 -a $# -ne 6 ]; then
  echo ""
  echo "Usage: filewrite "
  exit 1
fi
TITLE=`echo ${TITLE} | tr [:blank:] _ | tr : _ | tr / _ | tr "\134" _`;
TARGETFILE=${DEVICE_URI#filewrite:} ;
GREPSTRING="not accepting" ;
if lpstat -a $TARGETFILE | grep | "$GREPSTRING" &> /dev/null ; then
  echo "ERROR: printer $TARGETFILE not accepting jobsss....."
  exit 1
fi
cat $FILE > $TARGETFILE ;
chown :users /home/profit-master/* ;
chmod 770 /home/profit-master/* ;
exit 0


4. Outpup from cups error log

D [19/Sep/2008:15:10:59 -0600] Print-Job ipp://localhost/printers/fileprinter
D [19/Sep/2008:15:10:59 -0600] add_job: setting context of job to UNKNOWN SL
D [19/Sep/2008:15:10:59 -0600] add_job: requesting-user-name="lp"
I [19/Sep/2008:15:10:59 -0600] [Job 49] Adding start banner page "none".
I [19/Sep/2008:15:10:59 -0600] Saving subscriptions.conf...
I [19/Sep/2008:15:10:59 -0600] [Job 49] Adding job file of type application/vnd.cups-raw.
I [19/Sep/2008:15:10:59 -0600] [Job 49] Adding end banner page "none".
I [19/Sep/2008:15:10:59 -0600] [Job 49] Queued on "fileprinter" by "lp".
D [19/Sep/2008:15:10:59 -0600] [Job 49] hold_until = 0
D [19/Sep/2008:15:10:59 -0600] [Job 49] Sending job to queue tagged as raw...
I [19/Sep/2008:15:10:59 -0600] Saving subscriptions.conf...
D [19/Sep/2008:15:10:59 -0600] [Job 49] job-sheets=none,none
D [19/Sep/2008:15:10:59 -0600] [Job 49] banner_page = 0
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[0]="fileprinter"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[1]="49"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[2]="lp"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[3]="(stdin)"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[4]="1"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[5]="finishings=3 number-up=1 job-uuid=urn:uuid:5815b191-6e99-3e2c-5fea-afb3e36f29a3"
D [19/Sep/2008:15:10:59 -0600] [Job 49] argv[6]="/var/spool/cups/d00049-001"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[0]="CUPS_CACHEDIR=/var/cache/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[1]="CUPS_DATADIR=/usr/share/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[2]="CUPS_DOCROOT=/usr/share/cups/www"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[4]="CUPS_REQUESTROOT=/var/spool/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[5]="CUPS_SERVERBIN=/usr/lib/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[6]="CUPS_SERVERROOT=/etc/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[7]="CUPS_STATEDIR=/var/run/cups"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[8]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[9]="SERVER_ADMIN=root at myserver.mydomain.com"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[10]="SOFTWARE=CUPS/1.3.7"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[11]="TMPDIR=/var/spool/cups/tmp"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[12]="USER=root"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[13]="CUPS_SERVER=/var/run/cups/cups.sock"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[14]="CUPS_ENCRYPTION=IfRequested"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[15]="IPP_PORT=631"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[16]="CHARSET=utf-8"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[17]="LANG=en_US.UTF8"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[18]="PPD=/etc/cups/ppd/fileprinter.ppd"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[19]="RIP_MAX_CACHE=8m"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[20]="CONTENT_TYPE=application/vnd.cups-raw"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[21]="DEVICE_URI=filewrite:/home/profit-master/test.prn"
D [19/Sep/2008:15:10:59 -0600] [Job 49] envp[22]="PRINTER=fileprinter"
I [19/Sep/2008:15:10:59 -0600] [Job 49] Started backend /usr/lib/cups/backend/filewrite (PID 2964)
I [19/Sep/2008:15:10:59 -0600] Saving subscriptions.conf...
D [19/Sep/2008:15:10:59 -0600] cupsdProcessIPPRequest: 9 status_code=0 (successful-ok)
D [19/Sep/2008:15:10:59 -0600] cupsdCloseClient: 9
D [19/Sep/2008:15:10:59 -0600] cupsdAcceptClient: skipping getpeercon()
D [19/Sep/2008:15:10:59 -0600] cupsdAcceptClient: 9 from localhost (Domain)
D [19/Sep/2008:15:10:59 -0600] cupsdReadClient: 9 POST / HTTP/1.1
D [19/Sep/2008:15:10:59 -0600] cupsdAuthorize: No authentication data provided.
D [19/Sep/2008:15:10:59 -0600] CUPS-Get-Printers
D [19/Sep/2008:15:10:59 -0600] cupsdProcessIPPRequest: 9 status_code=0 (successful-ok)
D [19/Sep/2008:15:10:59 -0600] cupsdReadClient: 9 POST / HTTP/1.1
D [19/Sep/2008:15:10:59 -0600] cupsdAuthorize: No authentication data provided.
D [19/Sep/2008:15:10:59 -0600] CUPS-Get-Classes
D [19/Sep/2008:15:10:59 -0600] cupsdProcessIPPRequest: 9 status_code=0 (successful-ok)
D [19/Sep/2008:15:10:59 -0600] cupsdCloseClient: 9
D [19/Sep/2008:15:10:59 -0600] PID 2964 (/usr/lib/cups/backend/filewrite) exited with no errors.
D [19/Sep/2008:15:10:59 -0600] [Job 49] File 0 is complete.
I [19/Sep/2008:15:10:59 -0600] [Job 49] Completed successfully.






More information about the cups mailing list