Linux Printing Part II
- 0
- Add a Comment
- No Related Post
Linux Printing - Part II
Yesterday, we talked about the Linux printer daemon, lpd, and it’s crucial role in monitoring and controlling files sent to a printer. You’ll remember that lpd regularly checks the print spool for waiting files, copies itself, and turns over control of the spool to the child lpd. This child lpd then releases files from the spool for printing, using a “first in, first out” protocol.
So, how does lpd know where the spool is located? That’s the job of another Linux configuration file - /etc/printcap. The printcap file, in essence, defines the connection between your printer hardware (the printer itself and the hardware port to which it’s attached) and the Linux programs that control the printing process.
In most current distributions, the task of writing the /etc/printcap file is handled by a gui interface. The most common is printconf-gui. If you’re using RedHat or Mandrake and installed this file when you first set up your system, you’ll need to use the command:
/usr/sbin/printconf-gui
You’ll see a pretty gui that will guide you through the process. Today, we’ll start a walk through the /etc/printcap file itself, rather than creating one with the gui, so you can get an understanding of what goes on in the background to print documents in Linux.
Here’s the muscle of a typical /etc/printcap file:
HP880C:\
:sh:\
:ml=0:\
:mx=0:\
:sd=/var/spool/lpd/HP880C:\
:af=/var/spool/lpd/HP880C/HP880C.acct:\
:lp=|/usr/share/printconf/util/smbprint:\
:lpd_bounce=true:\
:if=/usr/share/printconf/util/mf_wrapper:
We’ll break this out line by line, but let’s first talk about some common requirements for the /etc/printcap file.
- A single printer is defined in a single line in printcap. A single line can be continued by using the backslash character at the end. This makes the printcap code more easily human-readable.
- Fields in the printcap entry are started and end with a colon (:). Fields can be empty, though a line entry in printcap cannot.
- The first field in the entry names the printer and, traditionally, contains no beginning colon.
- The printcap file must contain a default printer.
- Each printer must have an lp variable. This is the actual connection from the software to the hardware. In printcap entries containing a printer attached directly to the computer (a local printer), the lp variable is defined as lp=/dev/lp0, or the first [0] [l]ocal [p]rinter [dev]ice.
Now, let’s break out this printcap example line by line.
- HP880C:\ - names the default printer. In this case, it’s the Hewlett-Packard 880 sitting on my desk. This name can be any combination of alphanumeric characters. It’s intended as much to define the printer for the user as to define it for the lpd program.
- :sh:\ - suppresses the printing of a header or banner page. Inclusion alone of this variable will suppress this page.
- :ml=0:\ - the minimum number of printable characters to use as a check for the printability of the document. If the number of characters in the document falls below the value set in this variable, the document will be rejected as unprintable. A zero value overrides the printability check.
- :mx=0:\ - the maximum size of a print job, in blocks. This is normally set to 0, though a networked printer may require some adjustment.
- :sd=/var/spool/lpd/HP880C:\ - defines the spool directory used by the printer. Each printer requires a spool file. This spool should be located in /var/spool/lpd/default printer name.
- :af=/var/spool/lpd/HP880C/HP880C.acct:\ - the defined accounting file for the printer. This accounting file is required for each printer.
- :lp=|/usr/share/printconf/util/smbprint:\ - assigns a local printer device. In most cases, this will be /dev/lp0. In the case of our example, the printer is accessed via the laptop on my desk, using the smbprint program. As a result, the output of the print command is piped [|] to the smbprint program then shuffled off to the laptop and, eventually, to the printer.
- :lpd_bounce=true:\ - forces lpd to filter the job before forwarding to the printer. Filtering is especially important if your printer is primarily a Windows printer. Filters tweak the output in a way that a Windows printer can understand and follow.
- :if=/usr/share/printconf/util/mf_wrapper: - the location of the printing filter.
If you’re interested in understanding all the available printcap variables, you’ll find an excellent list at the LPRng-HOWTO. With the combination of this list and the general rules shown above, you’ll have all the tools you need to set up your printer manually.
Tomorrow, we’ll peek inside the most common gui printer configuration tool, and help you to set up your printer for Linux.
