4.23. Store and Forward Spool Queues

Up to now we have assumed that associated with each spool queue is a hardware printing device. When a job is sent to the spool queue the lpd server will take actions to filter it and then send it to the printing device.

However, we can also have store and forward spool queues. These queue act to simply buffer jobs and then forward them to another spooler. The following printcap entry shows how you can specify a store and forward queue.

    # store and forward using classical BSD :rm:rp
    lp:rp=pr:rm=host
      :sd=/var/spool/lpd/%P
      :server
    # store and forward using LPRng lp=pr@host
    lp:lp=pr@host
      :sd=/var/spool/lpd/%P
      :server


The legacy :rp (remote printer) and :rm (remote host) format can be used to specify the print queue and destination host for jobs sent to this queue. The LPRng :lp=pr@host format serves the same function, and has precedence over the :rm:rp form.

Edit the printcap file so it has contents indicated below, use checkpc -f to check the printcap, and then use lpc reread to restart the lpd server.

    lp:force_localhost
    lp:server
      :sd=/var/spool/lpd/%P
      :lp=lp2@localhost
    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: {238} % lpr /tmp/hi
    h4: {239} % lpq -lll
    Printer: lp@h4 (dest lp2@localhost)
     Queue: no printable jobs in queue
     Status: sending control file 'cfA029h4.private' to lp2@localhost at 09:39:57.719
     Status: completed sending 'cfA029h4.private' to lp2@localhost at 09:39:57.724
     Status: sending data file 'dfA029h4.private' to lp2@localhost at 09:39:57.727
     Status: completed sending 'dfA029h4.private' to lp2@localhost at 09:39:57.925
     Status: done job 'papowell@h4+29' transfer to lp2@localhost at 09:39:57.926
     Status: subserver pid 29031 exit status 'JSUCC' at 09:39:57.953
     Status: lp@h4.private: job 'papowell@h4+29' printed at 09:39:57.961
     Status: job 'papowell@h4+29' removed at 09:39:57.993
    Printer: lp2@h4
     Queue: no printable jobs in queue
     Status: no banner at 09:39:58.054
     Status: printing data file 'dfA029h4.private', size 3 at 09:39:58.054
     Status: printing done 'papowell@h4+29' at 09:39:58.054
     Status: accounting at end at 09:39:58.054
     Status: finished 'papowell@h4+29', status 'JSUCC' at 09:39:58.054
     Status: subserver pid 29033 exit status 'JSUCC' at 09:39:58.056
     Status: lp2@h4.private: job 'papowell@h4+29' printed at 09:39:58.056
     Status: job 'papowell@h4+29' removed at 09:39:58.069


As we see from the status, our job was sent to the lp spool queue first. It was store there and then the lpd server transferred it to the lp2 spool queue, where it was printed to the file /tmp/lp2.