Muli Ben-Yehuda's journal

October 10, 2005

adventures with emacs printing

Filed under: Uncategorized — Muli Ben-Yehuda @ 1:24 PM

When I started working at HRL, one of the first things I set up was
printing from Linux. It turned out to be pretty simple: create
postscript, and use a proprietary “pdpr” program on Linux to send the
postscript file to the printer. All was good and well, until while I
was abroad, new printers were installed that didn’t work with pdpr any
more, thus leading me to experiment with printing the modern
way. After installing the necessary packages and running a script to
set everything up (all thoughtfully provided by our system team!)
printing from mozilla, openoffice and the command line worked. I was a
happy camper.

Then I decided to go all the way and get printing from (x)emacs
working directly (rather than C-u M-x ps-print-buffer -> create a .ps
file -> print from the command line). A couple of hours spent
debugging ps-print.el, I had a script called “emacsprint”
which worked. Its contents?

muli@rhun:~$ cat bin/emacsprint

lpr $*

That’s all. Naturally, just calling lpr directly did not work. I
decided to leave it for the night and wait for
inspiration. Inspiration came today.

Compare and contrast:

"lpr" "-P [printername]"


"lpr" "-P[printername]"

If it’s not obvious, consider:

"lpr" "-P" "[printername]"

“-P [printername]” was getting passed to lpr as one argument, rather
than two, which lpr then did not know what to do with. When expanding
it via the wrapper script and $*, it was properly passed as two


  1. “lpr” “-P [printername]”
    This shouldn’t even be happening in the first place.
    — bi (

    Comment by Anonymous — October 10, 2005 @ 7:40 PM | Reply

    • good catch – that was due to me screwing up something unrelated 😉

      Comment by mulix — October 11, 2005 @ 5:38 AM | Reply

  2. use “$@” instead of $*
    Thanks to Tzafrir Cohen.

    Comment by omerm — October 10, 2005 @ 8:56 PM | Reply

    • doesn’t matter in this case, but more correct in general, yup.

      Comment by mulix — October 11, 2005 @ 5:38 AM | Reply

  3. Welcome back.
    Do you plan visiting the deep south (T.A.) anytime soon?

    Comment by omerm — October 10, 2005 @ 8:57 PM | Reply

    • yeah, maybe this weekend? or in Sukkot? when works for you guys?

      Comment by mulix — October 11, 2005 @ 5:39 AM | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

Blog at

%d bloggers like this: