Printer interface scripts
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 do the following:
- Initialize the printer port (the connection between the computer and the printer). The standard (/etc/lp/model/standard) interface script uses the stty command to initialize the printer port. See the stty command for more information.
- Initialize the physical printer (restore the printer to a normal state in case a previously printed file has left it in an unusual state), setting the character pitch, line pitch, page size, and character set requested by the user. The standard interface script uses the lp.set command to initialize the printer. See the lp.set command for more information.
- Print banner page (or pages), if required.
- Print the requested files. The standard interface script calls the lp.cat command to print the files. See the lp.cat command for more information.
- Report any errors to the print service. The standard interface script uses the lp.tell command to send descriptions of printer faults to the print service. The print service forwards that information as an alert to the print administrator. See the lp.tell command for more information.
The print service opens the printer port. The print service gives the printer port connection to the interface script as standard output and sets the printer to be the controlling terminal for the interface script. If the port experiences a hangup, a SIGHUP signal is sent to the interface script.
Many of the interface scripts provide special options that the user can specify by using the -o option with the lp command. See the lp command for more information.
The print service runs the interface script to send the print job to the printer, as shown in the following example:
/etc/lp/interfaces/printer id user title copies options file1 file2 ...
| Item | Descriptor |
|---|---|
| printer | The name of the interface script (the same as the printer name). |
| id | Request ID returned by the lp command. |
| user | Login name of user who made the request. |
| title | Optional title specified by the user. |
| copies | Number of copies requested by the user. |
| options | List of blank-separated options, specified by the user (using lp -o) or by the print service (from default values specified by the administrator with the lpadmin command). See the lp command for the list of options recognized by the standard interface. |
| file | Full path name of a file to be printed. |
When the interface script is invoked:
- Standard input comes from /dev/null.
- Standard output is directed to the printer port.
- Standard error output is directed to a file that will be displayed to the user who submitted the print request.
| Item | Descriptor |
|---|---|
| TERM=printer-type | Specifies the printer type. The value is used as a key for obtaining printer capability information from the extended terminfo database. |
| FILTER=pipeline | Specifies the filter to use to send the request content to the printer; the filter is given control of the printer. |
| CHARSET=character-set | Specifies the character set to use when printing the content of a print request. The standard interface script extracts the control sequences needed to select the character set from the terminfo database. |