LPRng Reference Manual: 3 May 2004 (For LPRng-3.8.27)
Prev | Chapter 4. Print Spooling Tutorial | Next

# 4.18. Routing Jobs To Print Queues

A routing queue is similar in concept to a load balance queue in that it transfers a job to a (different) print queue, but the job destination is chosen at the time the job is submitted to the queue rather than at the time the job is removed from the queue. A routing queue can modify the job control file, multiple copies of the same job can be sent to the same or different printers, and the job can be held, rejected, or processed immediately.

Edit the printcap file so it have the contents indicated below, create the `/tmp/lp2` and `/tmp/lp3` files with 0777 permissions. Create the `/tmp/router.script` with the contents indicated below, and give it 0755 (executable) permissions. Use `checkpc -f` to check the printcap, and then use `lpc reread` to restart the lpd server.

        # printcap
        lp:force_localhost
        lp:server
          :lp=/dev/null
          :sd=/var/spool/lpd/%P
          :router=/tmp/router.script
        lp2:force_localhost
        lp2:server
          :sd=/var/spool/lpd/%P
          :lp=/tmp/lp2
        lp3:force_localhost
        lp3:server
          :sd=/var/spool/lpd/%P
          :lp=/tmp/lp2

        # /tmp/router.script

        #!/bin/sh
        /bin/cat <<EOF
        dest lp2
        copies 2
        Cred
        end
        dest lp3
        end
        EOF
        exit 0

The `router.script` will write the routing information to its STDOUT. For our example, we want the destination lp2 to get two copies of the job and we want to change the class to red. Now run the following commands:

        h4: {282} % lpc stop all
        Printer: lp@h4
        lp@h4.private: stopped
        Printer: lp2@h4
        lp2@h4.private: stopped
        Printer: lp3@h4
        lp3@h4.private: stopped
        h4: {283} % lpq
        Printer: lp@h4 (dest lp@localhost) (printing disabled) (dest lp2, lp3)
         Queue: no printable jobs in queue
        Printer: lp2@h4  (printing disabled)
         Queue: no printable jobs in queue
        Printer: lp3@h4  (printing disabled)
         Queue: no printable jobs in queue
        h4: {284} % lpr /tmp/hi
        h4: {285} % lpq
        Printer: lp@h4 (dest lp@localhost) (printing disabled) (dest lp2, lp3)
         Queue: 1 printable job
         Server: no server active
         Rank   Owner/ID           Class Job Files        Size Time
        1      papowell@h4+235       A   235 /tmp/hi         3 16:14:22
         -          papowell@h4+235.1       ->lp2 <cpy 0/2>
         -          papowell@h4+235.2       ->lp3
        Printer: lp2@h4  (printing disabled)
         Queue: no printable jobs in queue
        Printer: lp3@h4  (printing disabled)
         Queue: no printable jobs in queue

The status reported for the spooled job indicates that the job is routed to lp2, and that two copies will be sent. The :destinations option in the printcap entry causes lpq to display the contents of the specified queues. Now execute the following commands:

        h4: {286} % lpc start
        Printer: lp@h4
        lp@h4.private: started
        h4: {287} % lpq
        Printer: lp@h4 (dest lp@localhost) (destinations lp2, lp3)
         Queue: no printable jobs in queue
         Status: job 'papowell@h4+235' removed at 16:14:37.491
        Printer: lp2@h4  (printing disabled)
         Queue: 2 printable jobs
         Server: no server active
         Rank   Owner/ID           Class Job Files        Size Time
        1      papowell@h4+235.1C1   A   235 /tmp/hi         3 16:14:36
        2      papowell@h4+235.1C2   A   236 /tmp/hi         3 16:14:37
        Printer: lp3@h4  (printing disabled)
         Queue: 1 printable job
         Server: no server active
         Rank   Owner/ID           Class Job Files        Size Time
        1      papowell@h4+235.2     A   237 /tmp/hi         3 16:14:37
        h4: {288} % more /var/spool/lpd/lp2/cfA235*
        Hh4.private
        Ppapowell
        J/tmp/hi
        Cred
        Lpapowell
        Apapowell@h4+235.1C1
        D2000-06-01-16:03:25.237
        Qlp
        N/tmp/hi
        fdfA235h4.private
        UdfA235h4.private

As you can see, two copies of the job has been transferred to lp2 and one to lp3, each with a different job number, If we examine the control file for the jobs in the lp2 spool queue, we will find that the C or class information has been changed to red.

For details about all of the capabilities of the routing filter, see Dynamic Routing. Here is a summary of the information that the routing filter can put into the routing file.

dest queue

  Route this job to queue. The queue@host form will transfer the job to the queue on the named host.

copies N

  Send N copies of this job to the destination.

priority C

  Set the job priority letter to C, where C is a single upper case letter.

Cvalue

  Set the control file line starting with C to Cvalue.

The exit status of the routing filter controls how the job will be processed. If the exit code is JSUCC (0), then the job will be processed normally, JHOLD will hold the job until released, JREMOVE will remove the job, and so forth.

Prev | Home | Next
Load Balance Queues and Printer Pools | Up | Job Options and the Z Control File Entry