4.24. Modifying Jobs In Transit - Bounce Queues

One of the major problems with store and forward operation is that the destination spool queue may not actually be a spool queue - it can be a printer. Many network printers provide an RFC1179 compatible network interface and act, for job forwarding purposes, like a host running a limited capability BSD print spooler.

Unfortunately, these network printers do not support filters, and jobs must be carefully tailored to meet their limited requirements. Do do this we need to apply a filter to modify the job in transit, and then forward the modified job. Traditionally, this is done by using the lpd_bounce flag, which causes lpd to process the job using the filters in the printcap entry, and concatenating all filter output to a single file. This single file is then forwarded to the destination. The reason for the single file is that in filtering the job multiple copies of files may be made, and the number of print files may exceed various system limits.

Edit the printcap and /tmp/testf files so they have the contents indicated below, give /tmp/testf executable permissions, use checkpc -f to check the printcap, and then use lpc reread to restart the lpd server.

    # set /tmp/testf to contain the following
    #   and chmod 755 /tmp/testf
    #!/bin/sh
    echo TESTF $0 $@
    /bin/cat
    exit 0
    
    # printcap
    lp:force_localhost
    lp:server
      :sd=/var/spool/lpd/%P
      :lp=lp2@localhost
      :lpd_bounce
      :filter=/tmp/testf
    lp2:force_localhost
    lp2:server
      :sd=/var/spool/lpd/%P
      :lp=/tmp/lp2
Execute the following commands to print the /tmp/hi file and observe the results:
    h4: {240} % lpr /tmp/hi
    h4: {241} % lpq -llll
    h4: {242} % lpq -llll
    Printer: lp@h4 (dest lp2@localhost)
     Queue: no printable jobs in queue
     Status: no banner at 09:55:53.681
     Status: printing data file 'dfA086h4.private', size 3, IF filter 'testf' at 09:55:53.683
     Status: IF filter finished at 09:55:53.713
     Status: printing done 'papowell@h4+86' at 09:55:53.714
     Status: sending job 'papowell@h4+86' to lp2@localhost at 09:55:53.734
     Status: connecting to 'localhost', attempt 1 at 09:55:53.735
     Status: connected to 'localhost' at 09:55:53.739
     Status: requesting printer lp2@localhost at 09:55:53.740
     Status: sending control file 'cfA086h4.private' to lp2@localhost at 09:55:53.752
     Status: completed sending 'cfA086h4.private' to lp2@localhost at 09:55:53.757
     Status: sending data file 'dfA086h4.private' to lp2@localhost at 09:55:53.758
     Status: completed sending 'dfA086h4.private' to lp2@localhost at 09:55:53.939
     Status: done job 'papowell@h4+86' transfer to lp2@localhost at 09:55:53.940
     Status: subserver pid 29088 exit status 'JSUCC' at 09:55:53.980
     Status: lp@h4.private: job 'papowell@h4+86' printed at 09:55:53.983
     Status: job 'papowell@h4+86' removed at 09:55:53.998
    Printer: lp2@h4
     Queue: no printable jobs in queue
     Status: subserver pid 29092 starting at 09:55:54.005
     Status: accounting at start at 09:55:54.005
     Status: opening device '/tmp/lp2' at 09:55:54.005
     Status: printing job 'papowell@h4+86' at 09:55:54.005
     Status: no banner at 09:55:54.006
     Status: printing data file 'dfA086h4.private', size 298 at 09:55:54.006
     Status: printing done 'papowell@h4+86' at 09:55:54.006
     Status: accounting at end at 09:55:54.006
     Status: finished 'papowell@h4+86', status 'JSUCC' at 09:55:54.006
     Status: subserver pid 29092 exit status 'JSUCC' at 09:55:54.008
     Status: lp2@h4.private: job 'papowell@h4+86' printed at 09:55:54.008
     Status: job 'papowell@h4+86' removed at 09:55:54.020


We have displayed a bit more status information so that we can see what the actions the lp queue is doing. It first prints the job to a temporary file, using the testf filter. Then it sends the contents of the temporary file to the lp2 queue. The lp2 queue receives the converted job and then prints it to the /tmp/lp2 file in turn.

When a bounce queue processes a job, a single file is produced and the control file for the job is modified to have a single data file with the bq_format (default f) literal format. This is very useful if you are trying to use the lpr -K (print copies) option and are trying to send jobs to a system that does not handle it properly.