Printing from a terminal session (lpr)

Feb 04, '01 07:18:37AM

Contributed by: sven

A while ago someone asked about how to configure osx for printing from the command line.

If you have a postscript printer in your network, this is actually pretty simple. Create a printcap file (named "myprintcap" for example) with jEdit, or vi or emacs or any other text editor:

lp:\
:lp=:rm=<printer ip or name>:rp=lp:\
:sd=/var/spool/lpd/lp:ty=PostScript:
Save this file somehere in your directory. Note: there should be backslashes terminating the first two lines. They were consumed by the scripts processing this hint, I guess. [Editor's note: Backslashes get stripped out, unless you enter in HTML mode, and use the character code '&#092;' for a backslash ... I've added them to the above lines.

Next you load this printcap into netinfo (line 1 below) and create the spool directory (line 2). Open a terminal and connect as root ("su"), then type:
niload printcap / < path/to/myprintcap
mkdir /var/spool/lpd/lp
Now you can print ps files from the command line by typing:
lpr file.ps
I should note that this hint is originally from the TeXshop readme.

Have fun,
Sven

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010204071837531