>I have a summer placement at Exeter (UK) University to explore the
>1. Modify or find a substitute for the lp command in order to provide
>simplex or duplex printing options from the command line.
There's no need to modify the lp binary. You simply need to install
an interface script that knows how to take the "-o duplex" or "-o simplex"
option to the lp command and send the corresponding command codes to the
printer at the start of the print job.
The HP Jetdirect software installs those kinds of interface scripts
for use with HP Laserjet printers (particularly ones on the network).
Lexmark provides MarkVision for their printers, and Xerox has one or
two similar software packages for their printers. Some other printer
manufacturers provide interface (aka "model") scripts on their web
sites or through their tech support departments.
The lp and lpr print commands scan the command line for -o option
keywords, and when the print server is a Solaris machine, any of
those options are passed to the print server along with the print
job. The Solaris print server (lpsched) then invokes the printer's
interface script and passes those option keywords in one of the
arguments to the script. It's up to the interface script to parse
the option keywords and send the initialization commands for those
options to the printer. (some option keywords can be commands to
the interface script itself, such as "nobanner")
The two interfaces provided with Solaris ("standard" and "netstandard")
are bourne shell scripts, as are the ones provided by HP's Jetdirect
software, but they don't have to be. They can be compiled programs,
perl scripts, or whatever seems the right programming medium in your
>2. Modify the lp sched command in order to trap non-postscript
>jobs sent to the postscript printer & non-text jobs sent to the text
No need to modify lpsched. It already has the ability to trap jobs
that are not in the right format and either reject them or automatically
send them through a print filter to convert them to the proper format
for the printer. The print filter can be a program or script of your
own devising to accomplish the goal.
The "automatically send jobs through a print filter" mechanism can be
utilized to send all print jobs through a sophisticated script or program
that decides if the format is correct (and writes the job to its output
so it will reach the printer), or if it's incorrect. When the job is
incorrect, the print filter can cause the job to fail, which sends a
notice back to the user who submitted the job, or the filter can convert
the data to the right format, or the filter can invoke an lp command
to send the job to another printer.
The print job can be run through a filter before the interface script
is invoked. This is what happens when lpsched determines that the
filter that needs to run is a "slow" filter. The print job can be run
through a filter that's invoked by the interface script itself. This
happens when lpsched determines the proper filter is a "fast" filter.
Lpsched has a mechanism for automatically detecting the format of a
print job, but it only detects whether or not the file is Postscript.
Files that are not in Postscript format are considered "simple" (text).
Other formats (PCL, gif, tiff, database, etc.) are not detected.
However, the user submitting the print job can use the -T argument to
the lp command to declare the format of the file, and lpsched will use
that information to make filter decisions.
So you have two points at which you can trap the print job and decide
whether it's in the wrong format and whether to convert, redirect, or
reject the print job. If the printer's content type is set to a specific
format (instead of "any"), then lpsched will invoke a print filter on
those jobs that aren't in the same format. Also, the interface script
(or program) can perform similar tests on the file and make similar
decisions on how to respond to files in the wrong formats.
>There is the possibility here of giving users the option to convert
>plain text to postscript in order to facilitate awareness of printer
>issues (ie printer malfunction caused by incorrect file types being
>received). However, this could be bypassed by converting jobs without
Solaris supplies a filter to do this. It's the "postprint" filter,
and the file that tells lpsched how to use it as a print filter is
So pretty much everything you've mentioned can be performed by the
interface script and print filters (which can also be scripts).
There's no need to hack the lp or lpsched programs. The designers
of the SVR4 print system anticipated these kinds of needs and
created the hooks where you could customize it in these ways.
The docs.sun.com web server has system admin guides with pretty good
tutorial and reference material on the print system.
I have a map of the United States that's actual size
-- Steven Wright