UNIX System Administration Handbook - Evi Nemeth [422]
• Short name – three or four characters, easy to type (e.g., “cer”)
• Full name – hostname and type of printer (e.g., “anchor-lj”)
• Descriptive name – other information (e.g., “LaserJet 5M in cer lab”)
The second two lines in our example contain configuration settings for device name (lp), spool directory (sd), and error log file (lf). The last line specifies a read-write connection with the printer (rw), the maximum file size (mx, unlimited in this case), the remote machine name (rm), and the remote printer name (rp).
Jobs submitted to the printing system without a specific destination are routed to the first printer that has “lp” as one of its aliases. You should not use lp as a printer’s primary name; that makes it difficult to change the default printer. If no printer has the name lp, the first printer in the printcap file is the system-wide default printer.
printcap variables
The flexibility of the printcap file is largely responsible for the BSD printing system’s adaptability. The details are documented in the printcap man page, so we discuss only the most common variables here. They’re shown in Table 23.2 on the next page.
Table 23.2 Commonly used printcap variables
All printcap entries should include at least a specification of the spool directory (sd), the error log file (lf), and the printing device (lp). If you have a modern printer, you should specify that the printer be opened for reading and writing (rw) so that the printer can send error and status messages back to the host.
sd: spool directory
Each printer should have its own spool directory. All spool directories should be in the same parent directory (usually /var/spool/lpd) and should have the same name as the full name of the printer they serve (anchor-lj in the preceding example). A spool directory is needed even if the printer being described lives on a different machine; spooled files are stored locally until they can be transmitted to the remote system for printing.
When you install a new printer, you must create its spool directory by hand. Permissions should be 775, with both owner and group daemon.
The spool directory for a printer also contains two status files: status and lock. The status file contains a one-line description of the printer’s state. This information is maintained by lpd and viewed with the lpq command. The lock file prevents multiple invocations of lpd from becoming active on a single queue and holds information about the active job. The permissions on the lock file are manipulated by lpc to control spooling and printing on the printer.
lf: error log file
Errors generated by print filters are logged to the file named in this variable. One error log can be shared by all printers, and it can be placed anywhere you like. When a log entry is made, the name of the offending printer will be included. Even remote printers should have log files, just in case of a communication problem with the remote machine.
See Chapter 11 for more information about log files.
Keep in mind that lpd sends error messages to syslog. Some filters send their error messages to syslog as well, leaving nothing in their printcap-specified log file. Check both of these locations when problems arise.
lp: device name
The device name for a printer must be specified if the printer is local. This name is usually the file in the /dev directory that represents the port to which the printer is attached. If the printcap entry addresses a network printer (that is, a printer on your LAN, not just a “remote” UNIX printer; see page 706), the lp variable should be a pointer to a dummy file. (We like to use /var/spool/lpd/printer/.null for our dummy files.) This variable does not have to be defined for remote printers, but if it is, the file must exist.
lpd uses an advisory lock on the lp file to determine if the printer is in use. Even if the printer is really accessed through a network connection, you should provide a value for the lp variable. Specify a unique file that already exists