Configuring /etc/printcap to Control Print System FunctionsThe /etc/printcap (printer capabilities) file is the glue that holds together all of what we have covered so far. It defines the name and aliases of a printer, what filter it uses, the conversion filters it can use, what option should be used to access the filter, where the printer spools its jobs, and more. An /etc/printcap file already exists on your system, but all the options are commented out. Therefore, in order to make it viable, you'll need to uncomment and change or add some options. Building the /etc/printcap FileThe format of /etc/printcap is fairly simple; it contains one or more multiline entries, one for each printer you want the system to be able to use. Here is a sample entry for a PostScript printer: laserjet4100|lp|local line printer:\ # :sh:\ :lp=/dev/lpt0:sd=/var/spool/lpd/laserjet4100:lf=/var/log/lpd-errs: :if=/usr/local/libexec/if-ps: The first line in this entry is divided into fields by the pipe (|) character; the first field gives the printer name, followed by any aliases you want to define in the second. In this case, the name of the printer is laserjet4100. It also has an alias of lp, which means it will be the default printer. Finally, the last field in the line is a long description of this printer. The second line is commented out. If it is uncommented, header pages (cover pages) will be printed that give the name of the user, the name of the file, and so on. This is a good idea if you have a lot of users printing to the same printerthey can easily find which printouts are theirs when they go to pick them up. The third line gives the information on where the printer is located. Here, :lp stands for local printer (as opposed to a remote printer). The printer is located on the first parallel port (/dev/lpt0). Also, :sd is the spool directory this printer uses, which is /var/spool/lpd/laserjet4100 (see the section in this chapter on creating and configuring the spool directory), and :lf, which stands for log file, is where this printer will log any errors it encounters. The fourth line specifies the input filter, or text filter, that should be used with this printer. In this case, you are using the if-ps filter (which is the text-to-PostScript filter you created earlier). Installing Conversion FiltersIf you want to install any conversion filters, /etc/printcap is also where those are handled. Install them simply by adding a new line in the printer entry containing the appropriate option (listed in Table 17.2), followed by the pathname of the filter. The format is the same as the :if line for the input filter.
Remember that these filters are not hard-coded. Therefore, if you have no use for a FORTRAN filter, for example, you can replace it with some other filter, simply by using that filter's pathname in the /etc/printcap file along with the option you want to assign to it. Note If you repurpose an lpr flag using the /etc/printcap file, you should make a change to the man page for lpr to indicate the changes you've made, for the benefit of your users who might be using the man page to learn how to print their files. Use the following commands to edit the man page: # gunzip /usr/share/man/man1/lpr.1.gz # vi /usr/share/man/man1/lpr.1 # gzip /usr/share/man/man1/lpr.1 Here is the line you would add beneath the :if line to install the groff-to-PostScript filter you created earlier, in place of the FORTRAN conversion filter: :rf=/usr/local/libexec/g2ps: Note that when you add this line, you will have to make a slight change to the :if line before it and add a backslash at the end. This is because lpd expects the entire line of information to be on one line, but the backslash escapes the newline character so that multiple lines are treated as a single line when read by the system. |