Although the print service is flexible enough to handle most printers and printing needs, you might require features that the standard print service does not accommodate.
You can customize the print service by:
When a user submits a request to print a file, the page size, character pitch, and line pitch (spacing) are normally determined from the form that it is printed on. If the user does not require a form, he or she can specify the page size and print spacing to use. If the user gives neither a form to use nor the page size and print spacing, defaults are used.
Note: The preceding information does not apply to PostScript printers.
By setting defaults for each printer, you can make it easier to submit print requests. For example, you can designate different printers as having different default page sizes or print spacing. You can dedicate one printer to printing wide (132-column) output, another to printing normal (80-columns, 66 lines) output, and yet another to printing letters in monospaced fonts (12 characters per inch, 8 lines per inch). Users simply route their file to the appropriate printer to get the style of output they want.
You can specify four default settings:
Specify the first two in columns and lines respectively (or in inches). Specify character pitch and line pitch in characters per inch (cpi) and lines per inch (lpi) respectively.
In addition, specify the character pitch as pica for 10 cpi, elite for 12 cpi, or compressed for the maximum cpi the printer can provide (up to a limit of 30 cpi).
To specify the default settings, use the following commands:
/usr/sbin/lpadmin -p printer_name -o width=scaled-number /usr/sbin/lpadmin -p printer_name -o length=scaled-number /usr/sbin/lpadmin -p printer_name -o cpi=scaled-number /usr/sbin/lpadmin -p printer_name -o lpi=scaled-number
Note: The lpadmin command uses the printer type to determine whether the settings are possible for the printer. Therefore, you must first set the printer type before you can specify these defaults.
For example, to specify a page width of 11 inches, a page length of 14
inches, character pitch to compressed, and line pitch of 3 lines per inch for
the printer barney, type:
/usr/sbin/lpadmin -p barney -o width=11i /usr/sbin/lpadmin -p barney -o length=14i /usr/sbin/lpadmin -p barney -o cpi=compressed /usr/sbin/lpadmin -p barney -o lpi=3
If you do not provide defaults, the page size and print spacing are set to
those available when the printer is initialized. You can determine what
the defaults are by first defining the printer configuration without providing
your own defaults, then using the lpstat
command to display the printer configuration. To display the default
page size and print spacing, type:
lpstat -p printer_name -l
Information similar to the following displays:
Default pitch: compressed CPI 3 LPI Default page size: Default page size: 11i wide 14i long
If you do not set the defaults, the lpstat command reports defaults from the terminfo database entry for the printer.
A banner is a page describing the print request (for example, printer name, user, date) that prints with the print job.
Use the following command to permit users to decide whether they want a banner printer:
/usr/sbin/lpadmin -o nobanner
A default wildcard entry is supplied in the /etc/lp/Systems file that allows connections to any system using BSD connections. This entry is as follows:
*:x:-:bsd:-:n:10:-:-:Allow all BSD connections
The presence of this entry allows a print server to accept connections from systems that are not explicitly configured as known systems.
Entries specifying the remote system name can still be added to the file using the lpsystem command.
Access to a printer can be controlled from the printer's users.allow and users.deny files. See the lpadmin command for more information.
Note: The wildcard entry is only used for incoming connection requests and not for outgoing requests.
If you do not want to separately control access to each printer on your system but you want the /etc/lp/Systems file to specify which remote systems have access to your printers, remove the wildcard entry from the file and add entries for the remote systems. To do this, perform the following:
/usr/sbin/lpsystem -r "*"
/usr/sbin/lpsystem system-name
The printer models file /usr/lib/scoadmin/printer/model.stz contains a list of supported printers and their attributes. Web-based System Manager uses this file to configure a new printer. The format is as follows:
key1:
attr1=val1
attr2=val2
key2:
...
The file includes a text description of each supported make and model, pointers to a printer interface script, and a terminfo entry. It can also contain additional information such as required serial line settings or supported content types.
The following attributes are available:
contents | A quoted, comma-separated list of the content types supported for a printer, usually just PS (for postscript), pcl (for Hewlett-Packard's Printer Control Language), or simple (for most other printers). Additional content types can be supported by creating Print Filters. SeeProviding Filters. This attribute is optional. |
interface | The Printer Interface Script should be set to standard in most cases. SeePrinter Interface Scripts. ThisThis attribute is mandatory. |
name | A text description of a printer make/model. This attribute is mandatory. |
terminfo | Is the name of the terminfo entry associated with this printer. See Using the terminfo Database. This attribute is optional. |
stty | Any serial or parallel line settings appropriate for the printer. This attribute is optional. |
In addition, each printer must have a unique key name associated with it, as shown in these examples:
canon-jet-10ex: name="Canon Bubble Jet 10ex" terminfo=bj-10ex interface=standard hp-laserjet: name="HP LaserJet (PCL)" terminfo=hplaserjet interface=standard contents=pcl stty="clocal -onlcr"
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.
Note: If you have an interface program that you have used with the print service of an older UNIX system, it should still work. Be aware, though, that several -o options have been standardized and will be passed to every interface program. These options may interfere with similarly named options your interface program uses.
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:
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.
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 ...
Arguments to the interface script are:
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:
The print service passes additional printer configuration information to
the interface script as the following shell variables:
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. |
If you have a printer that is not supported by adding an entry to the terminfo database, or if your printing needs are not supported by the standard or other interface scripts provided in the /etc/lp/model file, you can create your own printer interface script.
To create a customized interface script, do the following:
cd /etc/lp/model cp standard okidatanew
## Initialize the printer port
Modify 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 similar to the following:
stty mode options 0<&1
This command line takes the standard input for the stty command from the printer port. For example, the following stty command example 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 page
Some 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 turn 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 after 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 the job finishes 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 re-enable the printer.
To specify that fault messages be sent to the print service, use the lp.tell command. The standard printer interface code calls the lp.tell command 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, the interface script need not 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 must interrupt the printing of a file at any time, it kills the interface script with a signal 15 (see signal and kill for more information).
If the interface script stops upon 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) are 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.
The following table describes how the print service interprets exit
codes:
Code | Description |
---|---|
0 | The print job completed successfully. |
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 or mail - 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. |
By default, the print service uses the standard interface script, /etc/lp/model/standard. Use this interface script to 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 with the lpadmin command.
The following example adds a new printer called laser on printer port /dev/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 can be used only by the users doceng and docpub. (The following command example is split into multiple lines for readability.)
lpadmin -p laser -v /dev/tty01 \ -i /usr/doceng/laser_intface \ -I "i10,i300,impress" \ -u "allow:doceng,docpub"
The print service relies on the standard interface script and the terminfo database to initialize each printer and set up a selected page size, character pitch, line pitch, and character set. Thus, it is usually sufficient to have the correct entry in the terminfo database (/usr/lib/terminfo/terminfo.lp) to add a new printer to the print service.
The terminfo database identifies each printer by a short name, identical to the kind of name used to set the TERM shell variable. For example, the name in the terminfo database for the AT&T model 455 printer is 455.
To specify the terminfo type for your printer, use the -T option of the lpadmin command. By default, the terminfo database includes entries for many popular printers. Select the terminfo type that corresponds to your printer.
If terminfo does not include an entry for your printer, you might still be able to use the printer with the print service. However, you will not be able to use automatic selection of page size, pitch, and character sets, and you might have trouble keeping the printer set to the correct modes for each print request or using printer forms with the printer. In this case, you can either add an entry to terminfo (Adding a Printer Entry to the terminfo Database) for your printer or create a customized interface program (Creating Printer Interface Scripts) to use with the printer.
You can define hundreds of items for each terminal or printer in the terminfo database. However, the print service uses fewer than 50 of these, and most printers need even less than that. You can check items defined for a specific terminfo entry by typing the following command:
infocmp terminfo_name
To create a terminfo entry for your printer, do the following:
tic filename
After adding or deleting terminfo entries or changing values that govern pitch settings, page width and length, or character sets, stop and restart the print service.
Following are the print service terminfo entries and their
definitions:
terminfo entry | Description |
---|---|
Booleans: | |
daisy | Printer needs operator to change character set |
Numbers: | |
bufsz | Number of bytes buffered before printing |
* cols | Number of columns in a line |
* it | Tabs initially every # spaces |
* lines | Number of lines on a page |
orc | Horizontal resolution in units per character |
orhi | Horizontal resolution in units per inch |
orl | Vertical resolution in units per line |
orvi | Vertical resolution in units per inch |
cps | Average print rate in characters per second |
Strings: | |
* cr | Carriage return |
cpi | Change number of characters per inch |
lpi | Change number of lines per inch |
chr | Change horizontal resolution |
cvr | Change vertical resolution |
csnm | List of character set names |
mgc | Clear all margins (top, bottom, and sides) |
* hpa | Horizontal position absolute |
* cud1 | Down one line |
* cuf1 | Carriage right |
swidm | Enable double-wide printing |
rwidm | Disable double-wide printing |
* ff | Page eject |
* is1 | Printer initialization string |
* is2 | Printer initialization string |
* is3 | Printer initialization string |
* if | Name of initialization file |
* iprog | Path name of initializing program |
* cud | Move carriage down # lines |
* cuf | Move carriage right # columns |
* rep | Repeat a character # times |
* vpa | Absolute vertical position |
scs | Select character set |
smgb | Set bottom margin at current line |
smgbp | Set bottom margin |
* smgl | Set left margin at current column |
smglp | Set left margin |
* smgr | Set right margin at current column |
smgrp | Set right margin |
smgt | Set top margin at current line |
smgtp | Set top margin |
scsd | Start definition of a character set |
* ht | Tab to next 8-space tab stop |
The items marked with an asterisk (*) are available on your system. The remainder of the definitions can be added.
A preprinted printer form is a blank paper form that you load into your printer. An application typically generates a file that, when printed on the blank form, fills out the form. The print service includes facilities to create and administer forms.
To specify the format of forms, create a form description file.
For example, create a file called /tmp/check.desc and include all or any subset of the following information:
Page length: 66 Page width: 80 Number of pages: 2 Line pitch: 10 Character pitch: 16 Character set choice: any Ribbon color: blue Comment: Check form Alignment pattern: XXXX XXXXXXXXXXXXX XXXXXXXXX xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
The print service uses the alignment pattern to line up the forms before printing begins and prompts you to perform an alignment before printing.
Depending on your printer, specify page length in lines, inches (i), or centimeters (c). Specify page width in columns, inches (i), or centimeters (c). In the example above, page length is specified as 66 lines. If the printer recognizes inches, specify the page length as 11i.
After you have created a form, you must add it to the service. Choose a name that describes the form, because you use this name when you mount the form. The following command adds the form previously described:
lpforms -f check -F /tmp/check.desc
This command places the form in the /usr/spool/lp/admins/lp/forms file.
The print service imposes no fixed limit on the number of forms you may define. It is a good idea, however, to remove forms that are no longer appropriate. If you do not, users must examine a long list of obsolete forms when choosing a form. In addition, because the print service must occasionally look through all the forms listed before performing certain tasks, the failure to remove obsolete forms may require unnecessary processing by the print service.
To remove a form, type the following command:
/usr/sbin/lpforms -f form-name -x
You can limit the availability of certain forms to selected users. For example, you may want to limit access to checks to the people in the payroll department or accounts payable department.
The print service restricts the availability of a form by using the lists (provided by you) of users allowed or denied access to that form. If a user is not allowed to use a particular form, the print service will reject the request to print a file with it.
The method used to allow or deny users access to a form is similar to the method used to allow or deny users access to the cron and at facilities. Refer to the crontab command for more information.
If users on your system can access forms on a remote printer, all users included on the allow list for the local system must be included on the allow list for the remote system as well.
If, on the other hand, a local user is to be denied permission to use forms on a remote printer, it is not necessary for the deny lists in both the local and remote print services to include that user. By being included in only one of these deny lists, a user can be denied access to remote forms. As a courtesy to your users, however, make sure that any local users who are included in a deny list on a remote system are included in the corresponding deny list on your local system. This ensures that whenever a user on your system requests a form without authorization, the user is immediately informed that permission to use the form is being denied. If the local print service does not know that a user is denied permission to use a particular remote form, there will be a delay before the user receives a permission denied message from the remote system.
To add names to the allow list and remove them from the deny list, run the following:
lpforms -f form-name -u allow:user-list
To add names to the deny list and remove them from the allow list, run the following:
lpforms -f form-name -u deny:user-list
The user-list is a comma- or space-separated list of names of users. If you use spaces to separate the names, enclose the entire list (including the allow: or deny: but not the -u) in quotes. Each item in the list can include a system name.
Specifying allow:all allows all users. Specifying deny:all denies all users.
If you do not add user names to the allow or deny lists, the print service assumes that all users may use the form.
Before the print service starts printing files that need a preprinted form, you must mount the form on a printer. If alerting has been set on the form, you will be alerted when enough print requests are queued waiting for the form to be mounted (see Alerting to Mount Forms and Font Cartridges for information on alerting). Mounting a form involves loading it onto the printer and then informing the print service that it is mounted. It is sound practice to disable the printer first.
Until you have mounted a form on a printer, only print requests that do not require the form will be sent to the printer.
Use the following procedure to inform the print service that the form is mounted:
/usr/sbin/lpadmin -p printer-name -M -f form-name -a -o filebreak
If an alignment pattern has been registered with the form, you can ask that this be repeatedly printed after you have mounted the form, until you have adjusted the printer so that the alignment pattern looks correct.
The -o filebreak option tells the print service to add a form feed after each copy of the alignment pattern, if there is one. You must press the return key before each copy of the alignment pattern is printed.
The actual control sequence used for the form feed depends on the printer involved and is obtained from the terminfo database. If the alignment pattern already includes a form feed, omit the -o filebreak option.
The lpadmin command allows you to specify that a form or font on a specified printer is to be unmounted.
To unmount a form, use the following command:
/usr/sbin/lpadmin -p printer-name -M -f none
After you have defined a form to the print service, you can examine it with one of two commands, depending on the type of information you want to check. The lpforms command displays the attributes of the form. (The display produced by the lpforms command can be used as input. You may want to save it in a file for future reference.) The lpstat command displays the current status of the form.
Note: A form definition that is captured in a file can be used later to redefine the form if you inadvertently remove the form from the print service.
To display the status of a form, run the following:
lpstat -f form-name -l
To receive a shorter version of the output, omit the -l.
The long form of output, an example of which follows, is similar to the output of lpforms -l:
Page length: scaled-number Page width: scaled-number Number of pages: integer Line pitch: scaled-number Character pitch: scaled-number Character set choice: character-set[,mandatory] Ribbon color: ribbon-color Comment: comment Alignment pattern: [content-type] content
To protect potentially sensitive content, the alignment pattern is not shown if the lpstat command is used. See Creating a Printer Form for descriptions of these characteristics.