|
|
A ``printer interface script'' is a program that the print service uses to manage the printer each time it prints a file. The interface script initializes the printer, takes advantage of its particular capabilities, prints the file, and reports any errors.
The printer interface scripts are associated with the printer model and are located in /etc/lp/model. For example, the printer interface script for a PostScript® printer is called /etc/lp/model/PS. You can also create your own interface scripts or customize existing ones to suit your needs. See ``Creating printer interface scripts''.
Interface scripts:
Many of the interface scripts provide special options that the user can specify with the -o option to lp(1). (Read the appropriate interface file for this information.)
The print service runs the interface script to send
the print job to the printer:
/etc/lp/interfaces/printer id user title copies options file1 file2 ...
Arguments to the interface script are:
The print service passes additional printer configuration information to the interface script as shell variables:
See also:
If you have a printer that is not supported by simply adding an entry to the terminfo database, or if your printing needs are not supported by the standard or other interface scripts provided in /etc/lp/model, you can create your own printer interface script.
To create a customized interface script:
## Initialize the printer portModify the code in the standard interface script. It sets both the default modes and the adjusted modes given by the print service or the user with a line like:
This command line takes the standard input for the stty
command from the printer port.
For example, this stty command line sets the baud rate
to 1200bps and sets some of the option modes:
stty -parenb -parodd 1200 cs8 cread clocal ixon 0<&1
# Here you may want to add other port initialization code.
## Print the banner pageSome applications, when run with certain printers, may require that you turn off page breaking. If you must turn off page breaking, you can modify the standard interface program (/usr/lib/lp/model/standard) at this line:
if [ -n "${FF}" -a "no" = "${nofilebreak}" ]Change the no to yes to shut off page breaking.
One way of alerting the administrator to a printer fault is to exit with a code of 129. Unfortunately, if the interface script exits, the print service reprints the print job from the beginning once the fault is cleared. To get an alert to the administrator without reprinting the entire job, specify that the interface script send a fault message to the print service, but wait for the fault to clear. When the fault clears, the interface script resumes printing the job. When finished printing, the interface script can exit with zero as if the fault never occurred. An added advantage is that the interface script can detect when the fault is cleared automatically so that the administrator does not have to reenable the printer.
To specify that fault messages be sent to the print service, use lp.tell(1M). The standard printer interface code calls lp.tell(1M) with the LPTELL shell variable. The lp.tell program sends its standard input to the print service. The print service forwards the message as an alert to the administrator. If its standard input is empty, lp.tell does not initiate an alert. Examine the code immediately following these comments in the standard interface script for an example of how to use the lp.tell (LPTELL) program:
# Here's where we set up the $LPTELL program to capture # fault messages. # # Here's where we print the file.With the special exit code 129 or lp.tell, there is no longer the need for the interface script to disable the printer itself. Your interface script can disable the printer directly, but doing so overrides the fault-alerting mechanism. Alerts are sent only if the print service detects that the printer has faulted and the special exit code and lp.tell program are its main detection tools.
If the print service has to interrupt the printing of a file at any time, it kills the interface script with a signal 15 (see signal(2) and kill(1) for more information).
If the interface script dies from receipt of any other signal, the print service assumes that future print jobs are not affected and continues to use the printer. The print service notifies the person who submitted the print job that the job did not finish successfully.
The signals SIGHUP, SIGINT, SIGQUI, and SIGPIP (trap numbers 1, 2, 3, and 13) start out being ignored when the interface is invoked. The standard interface script changes this to trap these signals at appropriate times, interprets these signals to mean that the printer has a problem, and issues a fault.
Exit codes
Code | Meaning to the print service |
---|---|
0 | The print job completed successfully. If a printer fault occurred, it was cleared. |
1 to 127 | The print service encountered a problem in printing the job (for example, there were too many nonprintable characters or the job exceeded the printer's capabilities). This problem does not affect future print jobs. The print service should notify the person who submitted the print job - via write(1) or mail(1) - that an error occurred in printing the job. If a printer fault occurred, it was cleared. |
128 | Reserved for internal use by the print service. Interface scripts must not exit with this code. |
129 | The print service encountered a printer fault in printing the job. This problem affects future print jobs. If the fault recovery for the printer directs the print service to wait for the administrator to fix the problem, the print service should disable the printer. If the fault recovery is to continue printing, the print service should not disable the printer, but try printing again in a few minutes. |
> 129 | Reserved for internal use by the print service. Interface scripts must not exit with codes in this range. |
See also:
By default, the print service uses the standard interface script, /etc/lp/model/standard. This interface script should handle most of your printing needs.
To change the interface script after you add the printer,
You can specify an interface program using the -i option of lpadmin(1M).
The following example adds a new printer called
laser on printer port /dev/term/tty01.
It uses a customized interface program,
located in the directory
/usr/doceng/laser_intface.
It can handle three file types--i10,
i300, and impress--and
it may be used only by the users
doceng and docpub.
(The following command line is split into
multiple lines for readability.)
lpadmin -p laser -v /dev/term/tty01 \
-i /usr/doceng/laser_intface \
-I "i10,i300,impress" \
-u "allow:doceng,docpub"
See also: