User`s guide
4-163
Printer, Plotter, and Spooler Subsystem Programming
These are the arguments qprt tried to pass to enq. You get to see them because qprt found
echo instead of enq. The following command is equivalent to the command shown in step 2
above:
enq –P asc –o –f –o p /etc/motd
The –o option specifies that flags specific to the backend should be passed to the backend.
The –o option can be thought of as a free pass through the syntax checking that occurs
before the enq command builds a job description file and notifies the qdaemon of the
existence of a new job.
To continue with this side discussion of the –o flag before we return to a discussion of filters,
suppose that you want to set up a queue than will print a range of lines from an ASCII file.
For instance, suppose you read /usr/lpp/bos/README and find 35 lines that you want to
print so you can fax them to someone or tack them to your wall for reference. You could edit
/etc/qconfig and add the following lines:
partial:
device = partial
partial:
file = FALSE
backend = /usr/bin/partial
The file /usr/bin/partial could be a shell script with ownership of root.printq and with
permissions of 755 . Its contents could be as follows:
#!/bin/ksh
BEGIN=$1
END=$2
let DIFF=END–BEGIN+1
FILE=$3
/usr/bin/head –${END} ${FILE} | tail –${DIFF} | /usr/bin/qprt
–Pasc
Note that in Version 3.2.5, head and tail are in /usr/ucb, not /usr/bin, and that qprt is in
/bin, not /usr/bin.
If you wanted to print lines 189 through 223 of /usr/lpp/bos/README, you could use the
partial queue as follows:
qprt –Ppartial –o 189 –o 223 /usr/lpp/bos/README
When the backend executes, BEGIN is assigned 189, END is assigned 223, and DIFF is
assigned 35, which is the number of chosen lines. FILE is assigned /usr/lpp/bos/README.
The head command truncates /usr/lpp/bos/README immediately after the last requested
line. The output is piped to the tail command, which selects the last 35 lines of the truncated
file and pipes them to qprt, which will take input from stdin. qprt submits the lines to the
queue named asc.
A Filter that Maps Linefeeds to Carriage Returns and Linefeeds
Many users have written or purchased applications that prepare data streams to fill in the
blanks on pre–printed checks, invoices, bills–of–lading, or other forms. Printing these data
streams requires precise control of the physical printer. It is often the case that the job
processing pipeline created by piobe inserts or deletes enough data from the original data
stream that the output data no longer falls at the proper position on the pre–printed form.
The root user can frequently use lsvirprt to set the value of the _d attribute in the virtual
printer definition to p. On an ASCII queue on an IBM 4029 LaserPrinter, this would cause
piobe to select the ip pipeline to process the job. The ip pipeline is for passthru printing,
which means the formatter filters uses the passthru() routine to simply pass the input data
stream through to the printer without modification.
This frequently removes all the printer control problems that existed, but adds one new one.
When the formatter filter operates in passthru mode, the mapping of linefeeds to carriage
returns and linefeeds is disabled. The forms still don’t print correctly.