Following my posting to this (and about 6 other cross posted newsgroups)
regarding a printer filter problem which I encountered (See posting > Title:
HELP!!! Printer Filter Problem Date: 3 Nov 1992), I received a flood of
replies, some of which suggested a number of ingenious ideas, while an even
larger number were requests by other users with similar problems, asking me to
forward to them any solutions I might come by. To all and sundry who took the
time and patience to help, my sincere thanks for all the replies to this
posting and many others besides....... Instead of replying singly to each
person requesting a report on my progress, I thought it would be easier to
post a summary such as this to the newsgroups where I first spawned the
problem. Perhaps this could also be of use to computer-holics in general
...perhaps even part of an FAQ (??!!)......the problems involved in reliably
interfacing printers required to print a variety of document types across a
network seem to affect users universally, while their solutions are only
vaguely defined due to the lack of any standard method with which to approach
First of all to recap my original problem. We have just upgraded our
Hewlett Packard Laserjet IIIP to emulate postscript via the Pacific Page
Emulation Cartridge Ver. 4.31. This printer is mounted on a serial line
(/dev/ttya) on our Sun SPARCStation, and is used not only by the workstation
itself, but also a small PC community using PC-NFS V3.5b. Since the printer
cannot accomodate Postscript and native HP PCL concurrently, I sought to
enable automatic switching of the printer via an input filter, which, upon
determining the incoming document type (Postscript or PCL/other), would
download an escape sequence to the printer which would reset the printer to
the appropriate mode, wait for the reset to complete and then continue
printing the document itself. The escape sequences required are provided in
the documentation accompanying the cartridge.
To this end, I acquired a copy of James Clark's "lprps" software, which
comes with an input filter program, "psif", which examines the incoming print
file and executes a Bourne shell to enable proper handling of that document
type. This software is available from many anonymous FTP sites, and comes with
C source code. In its original form, psif will execute the shell "psif-ps" if
the incoming print document is Postscript, and "psif-text" for all other
types. I therefore set up the shells to not only print the document in
question, but to also download the appropriate escape sequence and "sleep" for
40 seconds before printing. The only problem I had was that when using
"psif-text" to switch from Postscript to HP PCL, the printer seemed to still
receive data even during the "sleep 40", after which the following error
appeared on the first page of the printout:
%%[ Error: undefined; OffendingCommand: %%
The solution to the problem eventually came from Markus Hirt and Ronald
Florence.....all that was required was to include a '%' at the beginning of
the escape sequence, so that the sequence is interpreted as a valid Postscript
command. My thanks to both Markus and Ronald.....the filter now works
perfectly. Here is the printcap entry I use (If you're mounting the printer
remotely via PC-NFS use the "raw" filter option in NFSCONF):
# Hewlett Packard LaserJet IIIP
:lp=/dev/ttya:br#19200:\ # Printer is on serial line ttya
:if=/usr/local/lib/psif:\ # Input filter
:tr=\004: # ^D required in postscript
# mode to tell the printer
# when end of job is reached.
If the incoming document is in postscript format, the shell "psif-ps" is
executed by the input filter program psif:
# psif-ps > A shell to switch printer to postscript if it is not already in
# postscript mode. The shell checks for the existence of an empty file called
# "pcl", which if found means the printer is in native HP PCL mode. An escape
# sequence is then sent to the printer to switch the printer to postscript,
# and the file "pcl" is renamed "postscript", signifying that the printer is
# now in that mode:
if [ -f /var/spool/lpd/printer_mode/pcl ]; then
mv /var/spool/lpd/printer_mode/pcl /var/spool/lpd/printer_mode/postscript
echo ["^[&l5257.1058J^M"] # Send escape sequence to standard output
# i.e. the printer.
sleep 40 # Put this shell to "sleep" for 40 seconds
# and wait for reset to complete.
cat # Send standard input (print file) to
# standard output (printer).
cat # If printer is already in postscript mode
# just print document.
If the incoming print file is anything other than Postscript, the shell
"psif-text" is executed in a similar manner:
# psif-text > A shell to switch printer to Hp PCL mode if not already in that
# mode. Operation is similar to above script, psif-ps.
if [ -f /var/spool/lpd/printer_mode/postscript ]; then
mv /var/spool/lpd/printer_mode/postscript /var/spool/lpd/printer_mode/pcl
echo ["%^[&l1057.32259J^M"] # Send escape sequence....note leading '%'.
sleep 40 # Wait for printer to reset.
cat # Print actual print data.
cat # Printer already in HP PCL mode. Only need
# to print document..no switching required.
Note I have used the SunOS echo command. To put an escape character such
as Esc (ASCII 27 in decimal)into the echo argument, use the vi editor and
press Ctrl V and then Ctrl [. I hope that the above is of some use to those
who requested it and perhaps also to those who did not. If anyone has any
questions or problems please feel free to e-mail me at either of the addresses
below. Once again thanks to one and all for all the replies and thanks to
Markus and Ronald. 'Till we meet again on the news-net.....
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:53 CDT