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 filenameYou 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access