COHERENT manpages
This page displays the COHERENT manpage for controls [Data base for the lp print spooler].
List of available manpages
Index
controls -- System Administration
Data base for the lp print spooler
/usr/spool/mlp/controls
The file /usr/spool/mlp/controls is the data base for the print spooler lp.
The superuser root can modify this file, either with a text editor or (to a
more limited extent) with the command lpadmin.
The format of controls is simple. Every blank line is ignored. All text
after the pound sign `#' is also ignored; you can use this feature to embed
comments in the file. The rest of the file consists of commands, each of
which has the format command=arguments.
The following describes the commands that you can embed in controls:
default=printer
This command sets the default printer, that is, the printer on which
jobs are printed when the user does not specify a printer on the lp
command line.
docopies=status
This command controls how lp prints multiple copies. If it is set to
on, then multiple copies are generated by invoking the printer's
control script for each time; if it is set to off, then multiple
copies are printed by telling the control script to do it. The
difference in the two methods is that the former gives you more
accurate information about the status of the job. If you wish to
print many copies and you want to monitor the job's progress, then set
docopies to on.
feed=status
The command localfeed tells lp whether to insert a formfeed character
between printing jobs sent to printers other than local printers.
Setting it to on tells lp to output a formfeed character; setting it
to off (or deleting it) tells it not to do so.
localfeed=status
The command localfeed tells lp whether to insert a formfeed character
between printing jobs sent to a local printer. (A local printer is
one plugged into the auxiliary port of a terminal.) Setting it to on
tells lp to output a formfeed character; setting it to off (or
deleting it) tells it not to do so.
logroll=hours
This command sets the time, in hours, at which the log file log is
renamed log.o and a fresh log file is begun. This is done so the log
file does not grow without bounds. The default value is 168 hours
(one week).
longlife=hours
Set, in hours, the ``life-expectancy'' of a file with a lifetime of L.
The default is three days (72 hours).
printer=name,device,script
This command defines a printer. lp accesses a printer by its name; it
cannot access a printer unless you name it in a printer command. name
names the printer. You can name a printer anything you like, so long
as it is one word. device names the device into which it is plugged.
script names the file in directory /usr/spool/mlp/backend that tells
how to massage the text being passed to the printer. You can write or
modify each script in that directory, and name each script whatever
you like. Note that one physical printer can have multiple names,
each using a different script; and one script can be shared by
multiple physical printers.
The command
printer = linenlq, /dev/lpt2, pannlq
names a printer linelq that is plugged into port /dev/lpt2, and whose
input is filtered through the contents of script
/usr/spool/mlp/backend/pannlq.
The command
printer = linepr, /dev/lpt2, linepr
names a printer linepr that is plugged into /dev/lpt2, and whose input
is filtered through the contents of script
/usr/spool/mlp/backend/linepr.
Note that these examples both name the same physical device. They
differ in the scripts they use to massage their input; this will be
described in detail below.
Finally, a printer can direct its output to any device, serial or
parallel, even /dev/null. For example:
printer=disk,/dev/null,disk
As will be shown below, the script disk writes its output into a
temporary file, so you can examine it without wasting a piece of
paper. The format of a printer-control script is described below.
You do not have to include a printer-control script in a printer
command; if you do not include one, the printer daemon lpsched uses
the command cat by default.
shortlife=hours
Set, in days, the ``life-expectancy'' of a file with a lifetime of S.
The default is 48 hours (two days).
templife=hours
Set, in minutes, the ``life-expectancy'' of a file with a lifetime of
T. The default is two hours.
Printer Control Scripts
A printer-control script massages the text being handed to a given printer.
The printer daemon lpsched redirects the output of the script (and
therefore, of every command within the script) to the device named on the
appropriate printer command named in the file /usr/spool/mlp/controls.
For example, consider the command
printer = linenlq, /dev/lpt2, pannlq
This command names a printer linenlq, declares that it is plugged into port
/dev/lpq2, and requests that lpsched massage input to the printer through
script /usr/spool/mlp/backend/pannlq. When lpsched processes a request that
is directed to printer linelq, it pipes the text of the job into script
pannlq, and redirects the output of pannlq to device /dev/lpt2.
It is important to remember that a printer-control script is not restricted
to a few commands that the spooler understands. Each is a true shell
script that can use any or all COHERENT commands to process text. The
limits of what a script can do are set only by your imagination.
Consider the following examples. In the discussion, above, of the command
printer, two scripts were mentioned: pannlq and linepr. Both send their
output to the same physical printer, but they process the input text in
different ways. The following gives the contents of linepr:
# filter the input through pr
pr
# throw a page at the end
echo "\f\c"
This script filters its input through the COHERENT command pr, which
paginates the text and puts a header on it. It then echoes a formfeed
character, to force the printer to throw a blank page at the end of the
job. As in other shell scripts, a pound sign `#' introduces a comment and
blank lines are ignored.
The following gives the contents of script pannlq:
# turn on near-letter-quality printing
echo "\021\033n"
pr
# turn off near-letter-quality printing
echo "\021\033P"
This script resembles the first, except that it includes commands to echo
the magic strings that turn on and turn off near-letter-quality printing on
this printer. This is one small example of the flexibility you can employ
in devising a script
As with other shell scripts, you can modify the behavior of a printer-
control script by setting environmental variables. For example, consider
the following variation on the script linepr:
if [ $HEADER ]; then
pr -h "$HEADER"
else
pr
fi
# throw a page at the end
echo "\f\c"
If you have exported the environmental variable HEADER, then this script
prints it at the top of each page; otherwise, it prints the default header.
You can use the same technique to do other work, such as force the printing
of a banner page.
The lp spooler reserves for its own use the environmental variables
MLP_COPIES, MLP_FORMLEN, MLP_LIFE, MLP_PRIORITY, MLP_SPOOL. Your scripts
can also use these variables. For more information on what each does, see
its entry in the Lexicon.
When lpsched uses a printer-control script, it passes it three arguments:
respectively, the sequence number of the print job (which identifies the
job uniquely); the name of the user; and the number of copies being
printed. You can use this information to control the printing of output;
for example, consider the following:
for i in `from 1 to $3`
do
pr -h "User $2 - Copy $i of $3"
done
echo "\f\c"
Note, too, that just as each physical printer can be accessed in different
ways via different scripts, so too the same script can be used by multiple
physical printers. If you had multiple Panasonic printers plugged into
your system, you could use the above script with each of them to massage
their input appropriately.
One last example. As noted above, the output of a printer-control script
can be directed to any device, not just a port. (It can also be redirected
to non-existent ports, so be careful when you enter your print commands.)
You can use this feature to redirect formatted text into files or other
interesting places. Consider the following printer command:
printer=disk,/dev/null,disk
This creates a ``printer'' named disk. The text filtered through file disk
is redirected to /dev/null. The contents of script disk show what this
device is up to:
tee /tmp/D$$
This script uses the COHERENT command tee to redirect its input both to the
standard output (which in the case of printer disk is thrown away) and into
a file in directory tmp. You can use this command to save input for further
examination later.
This discussion just scratches the surface of what you can do with the lp
print spooler and its control scripts. For more information, see the
Lexicon entries for printer and lp.
See Also
Administering COHERENT,
lp,
lpadmin,
MLP_COPIES,
MLP_FORMLEN,
MLP_LIFE,
MLP_PRIORITY,
MLP_SPOOL,
printer

















