How do I do Transparent or pass-through printing (slave printing)?
Many terminals, and just about all terminal emulators, have the
ability to do "local" printing. It's sometimes called "transparent
printing" or "pass-through", but the idea is that if the terminal
sees a special key sequence, it will start sending the data out
some other port (parallel or serial) until it sees some sequence
that tells it to stop.
In general terms, it's a lousy way to print. If you can possibly
do this any other way, you'll be much better off.
If you have an intelligent multiport card serving these
terminals, the vendor may have provided a way to make this better
(still not great, but definitely much better). Digiboard, for
example, creates transparent print devices that match your tty
id's- if you have terminals /dev/ttyb01 through /dev/ttyb16, you
also have /dev/prb01 through /dev/prb16, and as long as you have
told the Digiboard driver what escape sequence will start and stop
the printing (common terminal types like ansi and wyse60 are
configurable by name), the driver will do a nice job of handling
this for you: anything directed at those "pr" ports will get
If you don't have something like this, you use commands like
"lprint" (SCO OSR5) or you wrap your data in the start-stop
sequences yourself. You can find the start-stop sequences in
/etc/termcap: PN is the sequence to start local print; PS is the
sequence to stop. For example, if you look at the vt100 entry,
That means that to start local printing on a vt100 terminal (or
any ansi emulator) you'd echo an ESCAPE (ascii 27) followed by the
characters "[5i". You'd then send the stuff to be printed, and stop
with ESCAPE-[4i. You could also use "tput prtr_on" and "tput
prtr_off" to send the codes if they are defined in terminfo.
Everything you ever wanted to know about vt100 and more at VT100.net
But again, before you do this, consider your other choices: if
this is a printer on a Windows network, both Visionf and Samba can treat that as a
Unix printer. Or, there are Windows LPD programs that allow Windows
to be treated as an LPD server ( see /Reviews/alphacom3.html for one).
If this is Windows with an emulator, the emulation software will
either use the "default" Windows printer or will let you specify
which printer to use. You may not be able to use the so-called
"Windows" printers - the ultra-cheap inkjet printers that I do not recommend but that are so common nowadays and require tremendous support from drivers.
If it is a real terminal, the auxiliary printer port may be
serial or parallell. If it just says "AUX", it's serial.
Debug this stuff by putting the appropriate codes into a file
you can "cat". Put in the start code, some text, and the stop code.
You can use Vi for this: to
enter characters like ESC, hit CTRL-V first. So, to enter ESC [ 4 i
in vi, you would type:
i (enter insert mode)
Ctrl-V (want to enter control character)
ESC (end insert mode)
Your whole session might be (keys shown on separate lines for
clarity; don't press ENTER unless shown)
This will be printed
Cat that file, and you should print the text. If it prints on
the screen, the start codes are wrong. If it never stops going to
the printer, the stop codes are the problem. If nothing at all
happens, the codes are probably right but something is wrong at the
You can do that kind of test right at the command line, too:
echo "\033[5ithis is a test\033[4i"
That's for ansi passthru print codes, and if your terminal supports them,
then you will get "this is a test" on your printer. For this simple test
$TERM doesn't matter, though your shell does (for example, on Linux bash
you'd do "echo -e" instead of just "echo").
You may also have problems with flow control or the amount of
data sent. Some of the products like Digi allow you to control how
much print data is sent in each burst.
Unless you have ports like the Digi print ports, you shouldn't try this in a printer interface script. As Bon Rasmussen of Anzio said at Esker TUN + Transparent Printing:
You're heading in a dangerous direction. It is a
mistake to try to use the despooler system to do
passthrough print, for various reasons. The most
serious is that, because the despooler runs as a
separate process from the program generating the
printout, and they're both writing to the same
tty device, you'll get intermixing of printer
output and screen output. In other words, it
WON'T WORK reliably.
See also A guide to Anzio's Passthrough Printing
If your terminal gets hung up doing transparent print, it's just confused. Stop whatever process is sending the data and power cycle the terminal. That's all it should take.
If your terminal is not emulating Ansi or is doing an
incomplete emulation, those tests won't work. What
Perhaps you can choose another emulation. You'll need to know the codes (which you may find in terminfo or termcap). You
need to be able to do this test successfully before we can check anything else.
Once you can do that, the next step is to find out why the application can't print locally. Perhaps it thinks $TERM is
different from what the terminal is set to.
If that is not the issue, check to see if both terminfo and termcap have the same codes - the app may not be using what you expect.
It is easy to add codes if necessary. Adding this to a vt100 termcap does the job:
On that note, some apps use their own termcap or terminfo files and some use nothing but instead hard code the strings or have them as configurable items.
Cups and transparent printing
Like many all too helpful programs, Cups can give you grief with transparent printing. The problem is that Cups sees the serial line as busy because a getty or agetty process is using it.
The way around it is to fake Cups out with a named pipe. You create a printer using the named pipe as its serial device to wite to, and you have a background script reading that to send the data where you really want it.
For example, you created /dev/myterminalpipe and gave it perms so Cups can write to it. You create a serial printer in Cups that uses that device as its output. Your background script picks up data written to that and sends it to the place you want:
cat > /dev/prb01
See A solution to transparent printing using cups in Linux for details.
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Anthony Lawrence
Find me on Google+
© 2013-07-14 Anthony Lawrence