-->
Previous | Table of Contents | Next |
Apart from the programs discussed so far, each spool directory contains files that have the permissions -rw-rw-r-:
The errs file isnt required by Linux in order to print, but the file must exist for lpd to be able to log printer failures. The errs file can be called whatever you like as long as the name is specified in /etc/printcap. The errs file is usually created manually when you set up the spool area. The section Putting It All Together, later in this chapter, has more on this.
One very important file is /etc/printcap, which the following section describes in detail.
The /etc/printcap file is a text file that you can edit with your favorite editor. /etc/printcap should be owned by root and have the permissions -rw-r- - r- -.
The contents of /etc/printcap typically look very cryptic, but when you know how the file works, the contents are much easier to understand. To compound the problem, in some distributions theres no man page for printcap, and most printcap files are created either by programs or by people with no thought for readability. For your own sanity, make the layout of your printcap file as logical and readable as possible with lots of comments. And get the man page from the lpd sources if you dont already have it.
One printcap entry describes one printer. Essentially, a printcap entry provides a logical name for a physical device and then describes how data sent to that device should be handled. For example, a printcap entry defines what physical device is to be used, what spool directory any data for that device should be stored in, what preprocessing should be performed on the data, where errors on the physical device should be logged, and so forth. You can limit the amount of data that may be sent in a single job, or limit access to a printer to certain classes of users. The following shows how a printer is defined in the printcap file:
# Sample printcap entry with two aliases myprinter|laserwriter:\ # lp is the device to print to - here the first parallel printer. :lp=/dev/lp0: \ # sd means spool directory - where print data is collected :sd=/usr/spool/lpd/myprinter:
Its okay to have multiple printcap entries defining several different ways to handle data destined for the same physical printer. For example, a physical printer may support PostScript and HP LaserJet data formats, depending on some setup sequence being sent to the physical printer before each job. It makes sense to define two printers: one that preprocesses the data by preappending the HP LaserJet sequence and one that preappends the PostScript sequence. Programs that generate HP data send it to the HP printer, whereas programs generating PostScript print to the PostScript printer.
NOTE: If you dont designate a default printer via an environment variable or dont specify a printer on the lpr command line, Linux will route the print job to the lp printer. Thus, you should specify one of the printers in the printcap file as the lp printer.
Programs that change the data before its sent to the physical printer are called filters. Its possible for a filter to send no data at all to a physical printerthat is, the filter filters out everything.
The printcap file has too many fields to describe fully in this chapter, so only the most important ones are described. All fields in /etc/printcap (except for the names of the printer) are enclosed between colons and denoted by a two-letter code. The two-letter code is followed by a value that depends on the type of field. There are three types of fields: string, Boolean, and numeric. Table 20.3 describes the most common and most important fields; the following sections go into more detail.
Field | Type | Description |
---|---|---|
lp | String | Specifies the device to print tofor example, /dev/lp0 |
sd | String | Specifies the name of the spool directory for this printer |
lf | String | Specifies the file that errors on this printer are to be logged to |
if | String | Specifies the input filter name |
rm | String | Specifies the name of a remote printing host |
rp | String | Specifies the name of a remote printer |
sh | Boolean | Specifies this to suppress headers (banner pages) |
sf | Boolean | Specifies this to suppress end-of-job form feeds |
mx | Numeric | Specifies the maximum allowable print job size (in blocks) |
The lp Field
If you specify /dev/null as the print device, all other processing is performed correctly, but the final data goes to the bit bucketthat is, to nowhere. Printing to nowhere is rarely useful except for test printer configurations or with weird printers. When youre setting up a remote printer (that is, youve specified rm and rp fields), specify :lp=:.
Dont leave the field empty unless youre using a remote printer. The printer daemon complains if you dont specify a print device.
The lf Field
Whatever file you specify should already exist, or logging doesnt occur.
The if Field
Input filters are programs that take print data on their standard input and generate output on their standard output. A typical use of an input filter is to detect plain ASCII text and convert it into PostScriptthat is, raw text is its input and PostScript is its output.
When you specify an input filter, the printer daemon doesnt send the spooled print data to the specified device. Instead, it runs the input filter with the spooled data as standard input and the print device as standard output.
Previous | Table of Contents | Next |