O'Reilly logo

Running Mac OS X Tiger by James Duncan Davidson, Jason Deraleau

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Printing from the Command Line

Since the Mac OS X printing infrastructure is built on top of various Unix tools, it should be no surprise that you can print from the command line. You can print plain-text, PDF, and PostScript files from the command line by using the following command:

    lp filename

You can print the following kinds of files from the command line to any printer:

  • Plain text

  • PDF

  • PostScript

Because Mac OS X supports all these technologies in its print system, you don’t have to worry about sending PostScript to a non-PostScript printer—even if the printer is an old dot matrix printer. For example, to print out the contents of a PostScript file named requirements.ps, you would use the command shown in Example 10-5.

Example 10-5. Printing a text file to a printer

$ lp requirements.ps
request id is HP_LaserJet_5000-6 (1 file(s))

CUPS tells you that the job has been submitted and provides you with an identifier for the job. The identifier is composed of two parts: the name of the printer that the job will be printed on—in this case, HP_LaserJet_5000—and a sequence number—in this case, the number 6 indicates that this is the sixth job printed from this machine since CUPS was launched.

When called by itself, lp prints to the default printer on the system. To print to another printer, you have to specify its queue to the lp command. But how do you know the names of the printers attached to your computer? Use the lpstat command (refer back to Example 10-1 to see this in action).

Armed with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required