Rcjp's Weblog

February 20, 2006

Printing with lpr

Filed under: unix — rcjp @ 2:20 pm

Setup simple printing for my faithful (but crinkly paper heating noisy) oki printer. Just uncommented the lp section in /etc/printcap file and started the lpd daemon.

That wasn’t quite it though, printing a test with lptest 20 5 | lpr the text staircased across the page. Fortunately the solution was simple, just copied /usr/share/examples/hpif to /usr/local/libexec/if-oki chmod’ed it 555 and added an ‘input filter’ section to the printcap so
it now looks like


lp|local line printer:\\
    :sh:\\
    :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:\\
    :if=/usr/local/libexec/if-oki:

It would have been a two minute job if I hadn’t missed that I’d put a space after the 'if=' in the printcap entry, and spent twenty minutes scratching my head. Hmmm, I wish unix wasn’t so sensitive to such things.

Finally I added some ESC codes to the input filter to set the CPI to 15…


printf "\33&k2G33(s0p15h0s3b4102T" && cat && printf "\\f" && exit 0
exit 2

…now lpr filename all works nicely.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: