Monday, May 18, 2009

printcap


As with the termcap file, each entry in the printcap file is separated by a colon. Boolean characteristics, such as suppressing the header (sh), exist by themselves. Characteristics that can take on a value, such as the name of the output device, are followed by an equal sign (=) and the value (lp=/dev/lp1). For a complete list of characteristics, see the printcap man-page.

Each entry in the /etc/printcap file consists of single logical line. There is one entry for each printer on your system. To make the entry easier to read, you can break each logical line into several physical lines. As an example, lets look at the entry for the default, generic printer:

lp:lp=/dev/lp1:sd=/usr/spool/lp1:sh

The first part of the line is the name of the printer, in this case, lp. Each field is separated from the others with a colon, so in this example, there are three fields (plus the printer name).

If we were to break this example into multiple physical lines, it might look like this:

lp:\
:lp=/dev/lp1:\
:sd=/usr/spool/lp1:\
:sh

At the end of each physical line, there is a back-slash to tell lpd that the logical line continues. You'll also see that each field now has a colon before it and after it.

Although it is not necessary, you may find a file minfree in each of the spool directories. This is a simple text file that contains the number of disk blocks that should be left to keep the print spooler from filling up the disk. As a safety mechanism on a system with a lot of print jobs, the spool directory can be put on a separate file system. Should it fill up, the rest of the system won't suffer.

Often, data is sent directly to the printer devices, either because it is supposed to be raw ASCII text or because the program that created the data did its own formatting. This is referred to as raw data as the system doesn't do anything with it.

Sometimes the data is sent by the lpd daemon through another program that processes the data in preparation of sending it to the printer. Such programs are called filters. The stdin of the input filters receive what the lpd puts out. The stdout of the filter then goes to printer. Such filters are often called input filters and are specified in the printcap file with if=.

Because of this behavior, a print filter can be anything that understands the concept of stdin and stdout. In most cases on Linux, the input filters that I have seen are simply shell scripts. However, they can also be perl scripts.

With the exception of an input filter or a log file (which is specified using lf=), I have rarely used any other option for local printing. However, using the printcap file, you can configure your printer to print on a remote system, which is the subject of the next section.

No comments:

Post a Comment