lp Command

The lp command includes information for the AIX® Print Subsystem lp and the System V Print Subsystem lp.

AIX Print Subsystem lp Command

Purpose

Sends requests to a line printer.

Syntax

lp [ -c ] [ -dQueue ] [ -m ] [ -nNumber ] [ -oOption ] [ -s ] [ -tTitle ] [ -w ] [ Files ]

Description

The lp command arranges for the files specified by the Files parameter and their associated information (called a request) to be printed by a line printer. If you do not specify a value for the Files parameter, the lp command accepts standard input. The file name - (dash) represents standard input and can be specified on the command line in addition to files. The lp command sends the requests in the order specified. If the job is submitted to a local print queue, the lp command displays the following to standard output:

Job number is: nnn

where nnn is the assigned job number. To suppress the job number use the -s flag.

Flags

Item Description
-c Copies the files to be printed immediately when the lp command is run. The lp command copies files only when requested. No links are created. If you specify the -c flag, be careful not to remove any of the files before they are printed. If you do not specify the -c flag, changes made to the files after the request is made appear in the printed output.
-dQueue Specifies the print queue to which a job is sent.
-m Sends mail (see the mail command) after the files are printed. By default, no mail is sent upon normal completion of the print request.
-nNumber Prints the number of copies of printed output. The default number of copies is 1.
-oOptions Specifies that flags specific to the backend be passed to the backend. Thus, for each queue, other flags not described in this article can be included with the lp command. See the piobe command for a list of these flags. Specifying this flag is the same as specifying the -o flag for the enq command.
-s Suppresses the automatic return of job numbers. The lp command reports the job number as the default, the -s flag overrides the default.
-tTitle Specifies printing the title of the file on the banner page of the output.
-w Writes a message on the print requesters terminal after the files are printed. If the requester is not logged in, the mail command sends the message. If the user is logged in on multiple windows or terminals, the message may not be sent to the LFT where the command was issued. The message is sent to the first terminal on which the writesrv daemon sees the user to be logged in.
Note: If the -w flag is used in conjunction with the -m flag, the print requester will only receive mail and will not get a message on the terminal.

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To print the /etc/motd file on printer lp0 attached to device dlp0, enter:
    lp /etc/motd
  2. To print 30 copies of the /etc/motd file using a copy of the file, and to notify the user that the job is completed using mail, enter:

    lp  -c  -m  -n30  -dlp0:lpd0 /etc/motd

  3. To print the /etc/motd file using backend flags -f and -a, with a job title of blah, enter:

    lp  -t"blah"  -o -f  -o -a /etc/motd

  4. To queue the MyFile file and return the job number, enter:
    lp myfile
  5. To queue the MyFile file and suppress the job number, enter:

    lp  -s myfile

Exit Status

This command returns the following exit values:

Item Description
0 All input files processed successfully.
>0 No output device is available, or an error occurred.

Files

Item Description
/usr/sbin/qdaemon Contains the queuing daemon.
/var/spool/lpd/qdir/* Contains the queue requests.
/var/spool/lpd/stat/* Contains information on the status of the devices.
/var/spool/qdaemon/* Contains temporary copies of enqueued files.
/etc/qconfig Contains the queue configuration file.
/etc/qconfig.bin Contains digested, binary version of the /etc/qconfig file.

Related Information

The cancel command, enable command, lpr command, lpstat command, mail command.

The writesrv daemon.

The /etc/qconfig file.

Command for starting a print job (qprt command) in AIX Version 7.1 Operating system and device management.

Printing administration in the AIX Version 7.1 Printers and printing.

Printers, print jobs, and queues inAIX Version 7.1 Operating system and device management .

Print spooler in AIX Version 7.1 Printers and printing.

System V Print Subsystem lp Command

Purpose

Sends print requests

Syntax

lp [print-options] [files]

lp -i request-ID print-options

Description

The first form of the lp command arranges for the named files and associated information (collectively called a request) to be printed. If filenames are not specified on the command line, the standard input is assumed. The standard input may be specified along with named files on the command line by listing the filenames and specifying - for the standard input. The files will be printed in the order in which they appear on the command line.

The LP print service associates a unique request-ID with each request and displays it on the standard output. This request-ID can be used later when canceling or changing a request, or when determining its status. See the cancel command for details about canceling a request, and lpstat for information about checking the status of a print request.

The second form of lp is used to change the options for a request submitted previously. The print request identified by the request-ID is changed according to the print-options specified with this command. The print-options available are the same as those with the first form of the lp command. If the request has finished printing, the change is rejected. If the request is already printing, it will be stopped and restarted from the beginning (unless the -P flag has been given).

If you enter lp -?, the system displays the command usage message and returns 0.

Sending a print request

The first form of the lp command is used to send a print request either to a particular printer or to any printer capable of meeting all requirements of the print request.

Flags must always precede filenames, but may be specified in any order.

Printers for which requests are not being accepted will not be considered when the destination is any. (Use the lpstat -a command to see which printers are accepting requests.) However, if a request is destined for a class of printers and the class itself is accepting requests, then all printers in the class will be considered, regardless of their acceptance status.

For printers that take mountable print wheels or font cartridges, if you do not specify a particular print wheel or font with the -S flag, whichever one happens to be mounted at the time your request is printed will be used. The lpstat -p printer -l command is used to see which print wheels are available on a particular printer. The lpstat -S -l command is used to see what print wheels are available and on which printers. Without the -S flag, the standard character set is used for printers that have selectable character sets.

If you experience problems with jobs that usually print but on occasion do not print, check the physical connections between the printer and your computer. If you are using an automatic data switch or an A/B switch, try removing it and see if the problem clears.

Flags

-c
Make copies of the files to be printed immediately when lp is invoked. Normally files will not be copied, but will be linked whenever possible. If the -c flag is not specified, the user should be careful not to remove any of the files before the request has been printed in its entirety. It should also be noted that if the -c flag is not specified, any changes made to the named files after the request is made but before it is printed will be reflected in the printed output.
-d dest
Choose dest as the printer or class of printers that is to do the printing. If dest is a printer, then the request will be printed only on that specific printer. If dest is a class of printers, then the request will be printed on the first available printer that is a member of the class. If dest is any, then the request will be printed on any printer that can handle it. Under certain conditions (unavailability of printers, file space limitations, and so on) requests for specific destinations may not be accepted (see lpstat). By default, dest is taken from the environment variable LPDEST. If LPDEST is not set, then dest is taken from the environment variable PRINTER. If PRINTER is not set, a default destination (if one exists) for the computer system is used. If no system default is set and -T is used, dest will be selected on the basis of content-type specified with the -T flag [see the description of -T]. Destination names vary between systems (see lpstat).
-f form-name [-d any]
Print the request on the form form-name. The LP print service ensures that the form is mounted on the printer. If form-name is requested with a printer destination that cannot support the form, the request is rejected. If form-name has not been defined for the system, or if the user is not allowed to use the form, the request is rejected. (see lpforms). When the -d any flag is given, the request is printed on any printer that has the requested form mounted and can handle all other needs of the print request.
-H special-handling
Print the request according to the value of special-handling. Acceptable values for special-handling are defined below:
hold
Do not print the request until notified. If printing has already begun, stop it. Other print requests will go ahead of a held request until it is resumed.
resume
Resume a held request. If it had been printing when held, it will be the next request printed, unless subsequently bumped by an immediate request. The -i flag (followed by a request-ID) must be used whenever this argument is specified.
immediate
(Available only to LP administrators) Print the request next. If more than one request is assigned immediate, the most recent request will be printed first. If another request is currently printing, it must be put on hold to allow this immediate request to print.
 
-L locale-name
Specify locale-name as the locale to use with this print request. By default, locale-name is set to the value of LC_CTYPE. If LC_CTYPE is not set, locale-name defaults to the C locale.
-m
Send mail after the files have been printed. By default, mail is not sent upon normal completion of the print request.
-n number
Print number copies of the output. The default is one copy.
-o options
Specify printer-dependent options. Several such options may be collected by specifying the -o keyletter more than once (that is, -o option[1] -o option[2] ... -o option[n]), or by specifying a list of options with one -o keyletter enclosed in double quotes and separated by spaces (that is, -o "option[1] option[2] . . . option[n]").
nobanner
Do not print a banner page with this request. The administrator can disallow this option at any time.
nofilebreak
Do not insert a form feed between the files given, if submitting a job to print more than one file. This option is not supported by printers configured to use the PS (PostScript) interface.
length=scaled-decimal-number
Print this request with pages scaled-decimal-number long. A scaled-decimal-number is an optionally scaled decimal number that gives a size in lines, characters, inches, or centimeters, as appropriate. The scale is indicated by appending the letter i for inches, or the letter c for centimeters. For length or width settings, an unscaled number indicates lines or characters; for line pitch or character pitch settings, an unscaled number indicates lines per inch or characters per inch (the same as a number scaled with i). For example, length=66 indicates a page length of 66 lines, length=11i indicates a page length of 11 inches, and length=27.94c indicates a page length of 27.94 centimeters. This option may not be used with the -f option and is not supported by the PS (PostScript).
width=scaled-decimal-number
Print this request with pages scaled-decimal-number wide. (See the explanation of scaled-decimal-numbers in the discussion of length, above.) This option may not be used with the -f option and is not supported by the PS (PostScript).
lpi=scaled-decimal-number
Print this request with the line pitch set to scaled-decimal-number. (See the explanation of scaled-decimal-numbers in the discussion of length, above.) This option may not be used with the -f flag and is not supported by the PS (PostScript).
cpi=pica|elite|compressed
Print this request with the character pitch set to pica (representing 10 characters per inch), elite (representing 12 characters per inch), or compressed (representing as many characters per inch as a printer can handle). There is not a standard number of characters per inch for all printers; see the terminfo database for the default character pitch for your printer. This option may not be used with the -f flag and is not supported by the PS (PostScript).
stty=stty-option-list
A list of options valid for the stty command; enclose the list with single quotes if it contains blanks.
 
-P page-list
Print the pages specified in page-list. This flag can be used only if there is a filter available to handle it; otherwise, the print request will be rejected. The page-list may consist of ranges of numbers, single page numbers, or a combination of both. The pages will be printed in ascending order.
-q priority-level
Assign this request priority-level in the printing queue. The values of priority-level range from 0 (highest priority) to 39 (lowest priority). If a priority is not specified, the default for the print service is used, as assigned by the system administrator. A priority limit may be assigned to individual users by the system administrator.
-R
Remove file(s) after submitting the print request. Use this flag with caution.
-r
See -T content-type [-r] below.
-s
Suppress the ``request id is ...'' message.
-S character-set [-d any]
-S print-wheel [-d any]
Print this request using the specified character-set or print-wheel. If a form was requested and it requires a character set or print wheel other than the one specified with the -S flag, the request is rejected.

For printers that take print wheels: if the print wheel specified is not one listed by the administrator as acceptable for the printer specified in this request, the request is rejected unless the print wheel is already mounted on the printer.

For printers that use selectable or programmable character sets: if the character-set specified is not one defined in the Terminfo database for the printer (see terminfo), or is not an alias defined by the administrator, the request is rejected.

When the -d any flag is used, the request is printed on any printer that has the print wheel mounted or any printer that can select the character set, and that can handle all other needs of the request.

-t title
Print title on the banner page of the output. The default is no title. Enclose title in quotes if it contains blanks.
-T content-type [-r]
Print the request on a printer that can support the specified content-type. If no printer accepts this type directly, a filter will be used to convert the content into an acceptable type. If the -r flag is specified, a filter will not be used. If -r is specified but no printer accepts the content-type directly, the request is rejected. If the content-type is not acceptable to any printer, either directly or with a filter, the request is rejected.

In addition to ensuring that no filters will be used, the -r flag will force the equivalent of the -o 'stty=-opost' flag.

-w
Write a message on the user's terminal after the files have been printed. If the user is not logged in, or if the printer resides on a remote system, then mail will be sent instead. Be aware that messages may be sent to a window other than the one in which the command was originally entered.
-y mode-list
Print this request according to the printing modes listed in mode-list. The allowed values for mode-list are locally defined. This option may be used only if there is a filter available to handle it; otherwise, the print request will be rejected.

The following list describes the mode-list options:

-y reverse
Reverse the order in which pages are printed. This filter option is not supported by the LP Print Service.
-y landscape
Change the orientation of a physical page from portrait to landscape.
-y x=number,y=number
Change the default position of a logical page on a physical page by moving the origin.
-y group=number
Group multiple logical pages on a single physical page.
-y magnify=number
Change the logical size of each page in a document.
-o length=number
Select the number of lines in each page of the document.
-P number
Select, by page numbers, a subset of a document to be printed.
-n number
Print multiple copies of a document.
 

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Files

/var/spool/lp/*