COHERENT manpages
This page displays the COHERENT manpage for printer [How to attach and run a printer].
List of available manpages
Index
printer -- Technical Information How to attach and run a printer 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. Device Drivers Both the lpr and lp spoolers work through COHERENT's device drivers for the serial and parallel ports. The following gives an overview of these drivers. 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. Finding the Port Both spooler systems require that you be able to identify a port when you plug a printer into it. This can be more difficult than it seems, largely because the labels on your system's port may not be reliable: those labels reflect what MS-DOS thinks the ports are, and that may not be accurate. 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. 1. Plug the printer into an unused port. Load paper into the printer and turn it on. 2. Log in as the superuser root. 3. cd to directory /dev. 4. Send some output to each parallel port. The output must be something that your printer can print. If your new printer is a line printer, type: cat /etc/uucpname | pr > lpt1 If the printer is a laser printer that uses PCL, type: cat /etc/uucpname | hp > lpt1 Or, if the printer is a PostScript printer, type: cat /etc/uucpname | prps > lpt1 If text appears on your printer, then you have discovered the correct port. Jot down its name on a piece of paper, e.g., ``lpt1''. If nothing happens, try the command again for lpt2 and lpt3, until you have found the correct port and noted its name. 5. Exit from superuser status. The lpr Printing System Versions of COHERENT prior to release 4.2 use a version of the Berkeley command lpr to control printing. Although this command can print text onto printers plugged into either serial or parallel ports, they are almost always used through parallel ports; therefore, the descriptions in this section assume that all printers are plugged into parallel ports. To begin, lpr is actually a family of commands, as follows: hpd Daemon that prints files on the laser printer hpr Spool a file for printing on the laser printer hpskip Abort/restart printing a file on the laser printer lpd Daemon that prints files on the line printer lpr Spool a file for printing on the line printer lpskip 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. Dumb Printers To print on a line printer, simply use the command lpr. This command performs some formatting on the file, and invokes the line-printer daemon lpd to spool the file for printing. For example, to print the name of your system, use the command: cat /etc/uucpname | pr | lpr -B The option -B suppresses the printing of a banner page. You can also print the output of the text-formatting command nroff on a line printer, assuming that your line printer understands how to backspace. For example, the manual pages included with COHERENT were formatted with nroff. To print the text of this Lexicon entry on your line printer, type: man printer | lpr -B Epson-Compatible Printers The command epson massages text into a form that uses some of the text- formatting features of the Epson MX-80 printer and clones thereof. It is especially to be used with text that has been formatted with nroff: it turns nroff's character-backspace-character sequence into the Epson escape sequences for emphasized text and italics. epson writes its formatted output to the standard output, from which you can pipe it to a spooler or other program. For example, to print this manual page on an Epson-compatible printer, type: man printer | epson | lpr -B Laser Printers with PCL The Hewlett-Packard LaserJet, and its clones, use the Hewlett-Packard Control Language (HPCL) to control their behavior. Note that some laser printers, such as the Apple LaserWriter, use PostScript instead of HPCL; these printers are described below. The command hp prepares files to be printed on a HPCL printer. (Please do not confuse this with the device /dev/hp.) You should use it to prepare simple text, such as program listings, for printing on your laser printer. Like the command epson, hp massages the output of nroff into escape sequences used by a printer -- in this case, escape sequences used by a printer that's running the Hewlett-Packard Page Control Language (PCL). For example, to print this manual page on your PCL printer, type: man printer | hp | hpr -B The command hpr spools files to be printed on a laser printer. It works like the command lpr, except that it includes a number of special features; for example, you can use it to download LaserJet ``soft fonts'' into your printer. PostScript Printers Some laser printers use PostScript instead of HPCL to control their behavior. These printers expect their input to a program written in the PostScript language; if you send them ordinary text, they simply hang. To print ordinary text on a PostScript printer use the command prps, which is a PostScript version of the COHERENT command pr. It paginates text, draws a box around the page, and prints a simple header at the top of each page. For example, to print this manual page on a PostScript printer, use the command: man printer | prps | hpr -B Note that to print on a PostScript printer, you must use the -B option to the command hpr. If you do not, hpr will attempt to print a banner page in ordinary text on your printer, and your printer will hang. The lp Printing System Versions of COHERENT beginnning with release 4.2 also include the MLP spooler, which is an implementation of the System-V lp family of printing commands (hereafter called lp). 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: cancel Cancel the printing of a job chreq Change priority, lifetime, or printer for a job lp Spool one or more files for printing lpadmin Administer the print-spooler system lpsched Print jobs spooled with command lp; turn on printer daemon lpshut Stop the printer daemon lpstat Give the status of printer or print request pclfont Prepare a PCL font for downloading via MLP reprint Reprint a spooled print job route Let a user change his default printer Each of these commands is described in its own Lexicon entry. lp uses the following directories: /usr/spool/mlp/backend This directory holds the programs and scripts used to manage printers. /usr/spool/mlp/queue This directory holds all print requests. /usr/spool/mlp/route This directory holds files that name each user's default printer. lp's behavior is set by the contents of the following files: /usr/spool/mlp/controls This file holds lp's configuration data base. This data base links a printer by name to the device through which it is accessed, and to the configuration script (if any) with which its input is massaged. For information on how to modify it, see the Lexicon entry for controls. /usr/spool/mlp/log This file logs lp's activity. /usr/spool/mlp/status This file gives the status of each defined printer. To use lp, you must first use the command lpadmin to build a description file for each class of printer that you have plugged into your system. The description file names the class of printer (e.g., ``epson'' or ``laserjet'') and gives the information lp needs to manipulate input to the printer. For example, a script may include a stty command to set the port into a special mode, and one or more commands for filtering the input so it will print properly. A backend script can invoke commands like prps or epson to process text for printing. lp can perform sophisticated filtration; for example, it can correctly handle PostScript code that prints images or bar codes. See the Lexicon entry for lpadmin for more details on these scripts. 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'': temporary, in which a job survives two hours from the time of spooling; short-term, in which a job survives 48 hours; and long-term, 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: MLP_COPIES The number of copies to print. MLP_FORMLEN The number of lines on the page to be printed. MLP_LIFE The ``lifespan'' of a spooled file. MLP_PRIORITY The default priority to give each spooled file. MLP_SPOOL Set a number of user-specific variable, such as title of document, type of document, and data base. These variables can be set either by a user, or embedded in a script. Each is detailed in its own Lexicon entry. See Also Administering COHERENT, hpr, lp, lp [device driver], lpr, lpsched Notes When you link /dev/lp or /dev/hp to a device, it normally is linked to a ``cooked'' device, e.g., /dev/hp. This works correctly for character-based output, such as text (or PostScript files); however, if you are downloading binary data to the printer, such as graphics or fonts, be sure to use the ``raw'' device, e.g., /dev/rhp. Passing binary information through a ``cooked'' device will garble the data and distort the resulting image. 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; 1. Edit file /etc/conf/install_conf/keeplist. 2. Change the last line so that it reads as follows: echo '-I SHMMNI:SEMMNI:NMSQID:LPWAIT:LPTIME:LPTEST' 3. Type the following command to build a new COHERENT kernel: /etc/conf/bin/idmkcoh -o /testcoh 4. Shutdown and reboot with the new kernel. 5. Log in as the superuser root. 6. Set the kernel variables that control discipline of the printer. The driver uses a hybrid busy-wait/timeout discipline, to efficiently support in a multi-tasking environment a variety of printers whose buffers come in a multiplicity of sizes. The variable LPWAIT sets the time for which the processor waits for the printer to accept the next character. If the printer is not ready within the LPWAIT period, the processor then resumes normal processing for the number of ticks set by the kernel variable LPTIME. Thus, setting LPWAIT to an extremely large number (e.g., 1,000) and LPTIME to a very small number (e.g., one) results in a fast printer, but leaves very few cpu cycles available for anything else. Conversely, setting LPWAIT to a small number (e.g., 50) and LPTIME to a large number (e.g., five) results in efficient multi-tasking but also results in a slow printer unless the printer itself contains a buffer (as is normal with all but the least expensive printers). By default, LPWAIT is set to 400 and LPTIME to four. We recommend that you set LPWAIT to no less than 50 and no more than 1,000 and LPTIME to no less than one. The variable LPTEST determines wether the device driver checks to see if the printer is in an ``on-line'' condition before it uses the device. If your printer does not support this signal, you must set LPTEST to zero. To reset the values of LPWAIT, LPTIME, and LPTEST, edit file /etc/conf/mtune and set the parameters LPWAIT_SPEC, LPTIME_SPEC, and LPTEST_SPEC to the values that you want. Then use the command /etc/conf/bin/idmkcoh to build a new kernel. For details on this command, see its entry in the Lexicon. One word of caution to the wary: be sure to name your new kernel something innocuous, such as cohtest, to ensure that you do not clobber your current working kernel. 7. Reboot the new kernel and try printing again. 8. If your printer still exhibits problems, try increasing or decreasing the values of LPTIME and LPWAIT. Remember, each time you build a new kernel kernel, you must reboot in order for the new variables to take effect. The MLP printer spooler is distributed under license from Magnetic Data Operations, 9400B Two Notch Road, Columbia, SC 29223. The message cannot open device /dev/lp 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.