A printer is the device that transfers text to paper. The COHERENT system includes a system for spooling a file to one or more printers. Spooling means that the file is copied into a special area and printed by a daemon. With a spooler, more than one user can send files to the same printer at the same time, yet the files will not collide.
COHERENT also includes commands to prepare text for printing a variety of printers. These include line printers (that is, dot-matrix printers), Epson-compatible printers, laser printers that use the PCL page-description language, and printers that use PostScript. With COHERENT, you can run prepare text into a variety of formats, and print the output on any number of printers plugged into either parallel or serial ports.
COHERENT has implemented spooling in two ways. Versions of COHERENT prior to release 4.2 control printing through a version of the Berkeley command lpr. COHERENT release 4.2 and subsequent releases also control printing through the MLP print spooler, which implements a version of the System-V command lp and related tools. These systems differ greatly; each set is discussed in its own section below.
Before we begin to describe printing, please note that one major source of confusion for users is the fact that the same names occur over and over again. For example, please do not confuse the parallel-port's device driver lp with the print-spooler command lp or with the device /dev/lp. COHERENT inherits much of this confusion from the UNIX operating system; but we will do our best to make these terms clear to you. Caveat lector.
The driver lp manages parallel ports. The architecture of the PC permits your computer to have up to three parallel ports. Devices /dev/lpt1, /dev/lpt2, and /dev/lpt3 control, respectively, parallel ports 1, 2, and 3 in cooked mode. For more information, see the Lexicon entry for the driver lp.
COHERENT uses the driver asy to manage all serial ports, whether COM ports or multi-port cards. For details, see its entry in the Lexicon.
The following describes how to identify the port into which you have just plugged a printer. Note that these directions assume that you are printing to a parallel port; however, you can adapt them to serial ports as well, depending on the configuration of serial devices on your system.
cat /etc/uucpname | pr > lpt1
cat /etc/uucpname | hp > lpt1
cat /etc/uucpname | prps > lpt1
To begin, lpr is actually a family of commands, as follows:
hhppdd Daemon that prints files on the laser printer hhpprr Spool a file for printing on the laser printer hhppsskkiipp Abort/restart printing a file on the laser printer llppdd Daemon that prints files on the line printer llpprr Spool a file for printing on the line printer llppsskkiipp Abort/restart printing a file on the line printer
Each command has its own entry in the Lexicon, which describes it in detail.
The commands lpr and hpr dispatch text to printers: lpr to the printer plugged into device /dev/lp, and hpr to the printer plugged into device /dev/hp. Each of these devices is actually a link to the correct parallel port -- that is, to devices /dev/lpt1, /dev/lpt2, or /dev/lpt3, as described above. (For information on what a link is, see the Lexicon entry for the command ln). The fact that each command uses a ``generic'' device for its output makes it easy for you to dispatch files to the right device; however, it also means that you can have only one line printer and one laser printer plugged into your computer.
When you installed COHERENT, the installation program tried to link /dev/lp and /dev/hp for you automatically; however, you may need to set them yourself (say, because you have purchased a new printer).
To set these links correctly, first follow the directions given above to identify the port into which you have plugged the printer. Then, link that port to the device by which you will access the printer. If you are installing a line printer that you will access via the command lpr, then you must use the command ln to link the port to device /dev/lp; if, however, the printer is a laser printer that you will access via the command hpr, then you must link the port to device /dev/hp. For example, if you have plugged a line printer into port lpt1, then use the following commands:
ln -f lpt1 lp
ln -f rlpt1 rlp
(Please note that the last character in ``lpt1'' and ``rlpt1'' is the numeral one -- not a lower-case el.) If, however, you have plugged a laser printer into port lpt3, then use the following commands:
ln -f lpt3 hp
ln -f rlpt3 rhp
After you have made the links, use the command lpr or hpr (whichever is applicable) to test whether you have set up the links correctly. If you have not, go through the above procedure again.
The following describes how to use the lpr family of commands to print to a variety of printers.
cat /etc/uucpname | pr | lpr -B
man printer | lpr -B
man printer | epson | lpr -B
man printer | hp | hpr -B
man printer | prps | hpr -B
lp is considerably more sophisticated than the lpr commands. It permits you to have multiple printers of the same type (instead of just one laser printer and one line printer, as under lpr), which can be plugged into serial or parallel ports. It supports prioritization of printing jobs (that is, you can give some users or some types of jobs higher priority than others), lets each user set a default printer for his jobs, allows users to reprint their jobs easily, and allows applications to customize their output to take advantage of special printer features. It even supports local printing -- that is, it will format and print output onto a printer that is plugged into a terminal's auxiliary port.
lp's commands resemble those used by UNIX System V to control printing, so this system can work more easily with third-party applications. Note, however, that the MLP implementation of lp does differ in some important respects from the System-V original; therefore, users who have used lp under UNIX should pay close attention to the following descriptions.
lp consists of the following commands:
ccaanncceell Cancel the printing of a job cchhrreeqq Change priority, lifetime, or printer for a job llpp Spool one or more files for printing llppaaddmmiinn Administer the print-spooler system llppsscchheedd Print jobs spooled with command lp; turn on printer daemon llppsshhuutt Stop the printer daemon llppssttaatt Give the status of printer or print request ppccllffoonntt Prepare a PCL font for downloading via MLP rreepprriinntt Reprint a spooled print job rroouuttee Let a user change his default printer
Each of these commands is described in its own Lexicon entry.
lp uses the following directories:
You must then use lpadmin to link a given printer, by name, to the device through which it is accessed. You must have first identified the port into which each printer is plugged, as described above. These links are stored in file /usr/spool/mlp/controls. If you have prepared a configuration script for this printer's type, then you must link it to the given printer as well. For example, if you have prepared a configuration script for all PostScript printers and named it postscript, then you must link that script to every PostScript printer whose input you want to be massaged in this manner. Unlike the lpr printing system, lp lets you attach to your computer more than one printer of each type.
One last point: each ``printer'' should identify a given physical device plus a given means of accessing it. Thus, one physical printer can have more than one name if you plan to access it in more than one manner. See the Lexicon entry for lpadmin for more information on this topic.
Note that if a printer is a ``local printer'' -- that is, a printer plugged into the auxiliary port of the terminal that the user is using, the termcap description for that terminal must define the variables PS (print start) and PN (print end). Each printer's description file is stored in directory /usr/spool/mlp/backend.
You can use the command route to assign a default printer to each user. If the user has set a default printer for himself and if he does not name a printer on the lp command line, the output goes to that default printer. If the user has not set a default printer for himself and does not name a printer on his lp command line, the output goes to the system's default printer. This feature is an extension to the version of lp that is implemented by UNIX System V.
To spool a job for printing, use the command lp. A job consists either of one or more files, or of text read from the standard input. lp prefaces the job with a header that describes where and how the job is to be printed, then copies it into directory /usr/spool/mlp/queue. The name that lp gives the spooled job reflects its status, that is, the order in which it should be printed relative to other jobs that user has spooled. This allows each user to give a priority to the jobs that he has spooled.
Each job resides in the spooling directory until the printer daemon lpsched reads it and prints it. lpsched selects jobs for printing based on their relative priority, as shown in their names. It finds where the job is to be printed by reading its header; then it opens the description file for that printer and follows its directions for printing the job. To turn on the daemon, use the command lpsched by itself; to turn it off, use the command lpshut. If the spooler is shut down, jobs remain in /usr/spool/mlp/queue until you reawaken the daemon by issuing the command lpsched.
To see what files are being printed where, use the command lpstat. To cancel a printing request, use the command cancel.
A job remains ``alive'' in /usr/spool/mlp/queue until its ``life'' has expired; the life is set in its header. There are three types of ``lifetime'': _t_e_m_p_o_r_a_r_y, in which a job survives two hours from the time of spooling; _s_h_o_r_t_-_t_e_r_m, in which a job survives 48 hours; and _l_o_n_g_-_t_e_r_m, in which a job survives 72 hours. The default is short-term. When a job's life expires, lpsched removes it. A user can use the command chreq to change a job's lifetime or priority; or redirect it from one printer to another. While a job lives in the spool directory, a user can use the command reprint to reprint it. He can also use the command route to change his default printer.
Note that you should be very careful that jobs that include sensitive information -- e.g., the payroll checks or your resume -- do not linger in spool directory, where other users can reprint them. For information on resetting a job's lifetime, see the Lexicon entries for chreq and MLP_LIFE. You can change the default definitions of temporary, short-term, and long-term by editing controls. See its entry in the Lexicon for more information. Caveat utilitor!
The following environmental variables affect lp's default behavior:
A Some COHERENT 4.2 customers have experienced printing problems, including no printing, slow printing, or printing stops after a line or two. To fix this, one needs to do the following steps in exact order;
echo '-I SHMMNI:SEMMNI:NMSQID:LPWAIT:LPTIME:LPTEST'
/etc/conf/bin/idmkcoh -o /testcoh
A The message
cannot open device /dev/lp
A from lpr means either that the printer is not turned on, or that the device /dev/lp is not linked to the correct parallel-port device. Use the directions given above to find and link the correct device. The same applies when you receive this message from hpr.