Each printer on your system should have a name. By default, commands that send a file to a printer assume that the printer is named lp (a historical artifact; it stands for "Line Printer"). If you're using a single-user workstation and have a printer connected directly to your workstation, you can name your printer lp and forget about it.
In many environments, there are more options available: e.g., there are several printers in different locations that you can choose from. Often, only one printer will be able to print your normal documents: you may need to send your print jobs to a PostScript printer, not the line printer that the accounting department uses for billing.
There are two ways to choose a printer:
Printing commands in the lpr family accept the option -Pprinter. This includes lpr (Section 45.2), various scripts to format typeset documents, etc. For example, lpr -Pps file.ps sends the file file.ps to the printer named ps.
Commands in the lpr family recognize the PRINTER environment variable (Section 35.3); if PRINTER is defined, the command will read its value and choose a printer accordingly. So the command:
% setenv PRINTER ps -- or $ PRINTER=ps ; export PRINTER
ensures that the lpr-style print commands will send your documents to the printer named ps. The -P option overrides this environment variable, in case you need to send a particular print job to a different printer.
Commands in the lp family use the -d option to select a printer. So lp -d prfile.ps sends file.ps to the printer named pr; it's equivalent to the previous lpr example.
Commands in the lp family look for an environment variable named LPDEST, rather than PRINTER. So:
% setenv LPDEST ps -- or $ LPDEST=ps ; export LPDEST
ensures that the lp-style print commands will send your documents to the printer named ps. The -d option overrides this environment variable.
Note that Solaris and others that use lp can include both the lp and lpr print commands. This can make things confusing, particularly if you're using a script to process documents, and that script automatically sends your documents to the printer. Unless you know how the script works, you won't know which variable to set. I'd suggest setting both PRINTER and LPDEST for these systems.
By the way, if you have only one printer, but you've given it some name other than lp, the same solution works: just set PRINTER or LPDEST to the appropriate name.
-- ML
Copyright © 2003 O'Reilly & Associates. All rights reserved.