[wellylug] Fun with HPLjet4 printers

jumbophut jumbophut at gmail.com
Fri Jan 7 23:44:01 NZDT 2005


I have a system with an HPLjet4-compatible printer attached.  It is
currently running a Debian distribution with very little space.  In
fact, I have not been able to squeeze on printing utilities (no lp,
lpr, lpd).  But I still wish I could print stuff from time to time --
e.g. config files.

So, I figured it should be easy to just 'cat' stuff to /dev/lp0 (with
the parport_pc module loaded) and have the printer work.  It turns out
it is, once you've spent a day googling for the stuff you didn't know
you were supposed to look for :-).

So, for the benefit of other resource-constrained users, and just
because absolutely pointless arcana is fun...

echo -e "^[E" > /dev/lp0 && cat FILETOPRINT | fold -w 70 -s | pr
--length=64 | sed -e 's/\(.*\)$/\1^M/' > /dev/lp0 && echo -e "^[E" >
/dev/lp0

In a terminal, you get the ^[ by pressing Ctrl-V then Esc, and the ^M
by pressing Ctrl-V then Enter.

The commands will work with just a shell, textutils, and either the
cat/echo/sed commands or busybox (i.e. stuff that is on virtually
every system), provided /dev/lp0 has the right kind of printer at the
end of it.  The commands only work for plain text of course, and you
may need to fiddle with the 70 (chars per line) and 64 (lines per
page) settings to suit your needs.  (Indeed, fold and pr are not
strictly necessary for many documents, and removing them would cut the
dependencies to just a lightweight shell and busybox.)

There's also the slight problem that if any Ctrl-V+Esc codes are in
your document, you'll probably get garbage or truncated output.  (I
can't think why there would be, but it is possible I guess -- there
aren't any in the body of this email as you can check with a hex
editor).

I've had a look at how it might be done for Postscript, but that looks
harder because the postscript command to print text is '(text) show'
and it seems very likely that 'text' might have an embedded ')', which
would need to be escaped somehow.  Anyone care to enlighten me?

Cheers
Tony

-- 
Tony (echo 'spend!,pocket awide' | sed 'y/acdeikospntw!, /l at omcgtjuba.phi/')




More information about the wellylug mailing list