Controlling Traditional Unix Print Services


Code listing 7.1. Sample /etc/printcap entries for a local printer and a remote printer.
 # The primary printer, located in # location. primary|secondary|description   :sd=/var/spool/lpd/primary   :lp=/dev/outputDevice   :mx#0   :lf=/var/log/lpd/primary.log # The remote printer, located in # location. remote|description   :sd=/var/spool/lpd/remote   :rm=hostname   :mx#0   :lf=/var/log/lpd/remote.log 

What happens when a user sends a job to a printer using the standard lp command? The answer is, of course, "It depends."

Originally, the only kinds of printers available were plain-text printers. The more exotic and expensive models could bang out an entire line (or even an entire page) in one whack, but they were still limited to plain-text output.

Accordingly, the print services on Unix were designed to handle multiple users' sending plain-text files. The lpd would check the queued-up files and send them one after another to the printer, possibly sending a form feed between files.

Things got more exciting when printers capable of rendering complex graphics appeared, but as we'll see in this section, they can be handled behind the scenes.

Please note that if you'll be switching to CUPS (which is the default print engine on Fedora Core and Mac OS X), the /etc/printcap file will be controlled by the CUPS configuration tools, so you might want to skip this section.

To configure a line printer

Unix line printers are configured through the /etc/printcap file, which lists every known printer, its location, and its capabilities.

1.

Log in as root, or use su (or sudo) to become root.

2.

Using your favorite text editor, edit the /etc/printcap file.

3.

The printer entries in /etc/printcap go over multiple lines, with the # character indicating a comment line (Code List ing 7.1). A printer entry follows this format:

[View full width]

# The primary printer, located in # location.primary|secondary|description :sd=/var/spool /lpd/primary :lp=/dev/outputDevice :mx#0 :lf=/var/log/lpd/primary.log

  • The comment at the beginning should describe the printer and its location (and possibly other information) so that the admin istrator can keep things straight while editing the file.

  • Change primary to the primary name for this printer; lp is the name of the default printer, unless you change it. The optional secondary name is one or more aliases for this printer, separated by | (pipe) characters. The description entry goes until the end of the line and should describe the printer in a useful way.

  • Use the sd= property to specify a spool directory. This needs to be different for each printer, because print jobs will be stored here until lpd sends them to the printer. Naming the directory after the printer is a good idea.

  • Use the lp= property to specify the port that the printer is connected to, usually /dev/lpt0 or something similar (it's OS dependent, and it also depends on how you've got the printer connected). You can use rm=hostname instead of the lp= property if you're printing to a remote printer located at hostname.

  • The mx#0 entry tells lpd to accept any size print job. Set it to a smaller value (it's described in the man pages as being in "BLKSIZ blocks," which isn't helpful; BLKSIZ is a programming constant and is usually 512 bytes) to limit the size of print jobs.

  • The lf= property specifies the file for log entries related to this printer.

4.

Save the file and exit your text editor.

Tips

  • You don't need to restart lpd after editing the /etc/printcap file. The file is loaded every time someone sends a print job, so your changes are noticed right away.

  • Although Cygwin has an lpr command (lpr is the older, nonstandard version of lp), it's not quite the same as the Unix lpr command. It can, however, send raw (printer-formatted) data to a printer connected to your PC or to a shared printer on the Windows network.




    Unix Advanced. Visual QuickPro Guide
    Unix Advanced: Visual QuickPro Guide
    ISBN: 0321205499
    EAN: 2147483647
    Year: 2003
    Pages: 116

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net