1LP(P) POSIX Programmer's Manual LP(P)
2
3
4
6 lp - send files to a printer
7
9 lp [-c][-d dest][-n copies][-msw][-o option]... [-t title][file...]
10
12 The lp utility shall copy the input files to an output destination in
13 an unspecified manner. The default output destination should be to a
14 hardcopy device, such as a printer or microfilm recorder, that produces
15 non-volatile, human-readable documents. If such a device is not avail‐
16 able to the application, or if the system provides no such device, the
17 lp utility shall exit with a non-zero exit status.
18
19 The actual writing to the output device may occur some time after the
20 lp utility successfully exits. During the portion of the writing that
21 corresponds to each input file, the implementation shall guarantee
22 exclusive access to the device.
23
24 The lp utility shall associate a unique request ID with each request.
25
26 Normally, a banner page is produced to separate and identify each print
27 job. This page may be suppressed by implementation-defined conditions,
28 such as an operator command or one of the -o option values.
29
31 The lp utility shall conform to the Base Definitions volume of
32 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
33
34 The following options shall be supported:
35
36 -c Exit only after further access to any of the input files is no
37 longer required. The application can then safely delete or mod‐
38 ify the files without affecting the output operation. Normally,
39 files are not copied, but are linked whenever possible. If the
40 -c option is not given, then the user should be careful not to
41 remove any of the files before the request has been printed in
42 its entirety. It should also be noted that in the absence of the
43 -c option, any changes made to the named files after the request
44 is made but before it is printed may be reflected in the printed
45 output. On some implementations, -c may be on by default.
46
47 -d dest
48 Specify a string that names the destination ( dest). If dest is
49 a printer, the request shall be printed only on that specific
50 printer. If dest is a class of printers, the request shall be
51 printed on the first available printer that is a member of the
52 class. Under certain conditions (printer unavailability, file
53 space limitation, and so on), requests for specific destinations
54 need not be accepted. Destination names vary between systems.
55
56 If -d is not specified, and neither the LPDEST nor PRINTER environment
57 variable is set, an unspecified destination is used. The -d dest option
58 shall take precedence over LPDEST , which in turn shall take precedence
59 over PRINTER . Results are undefined when dest contains a value that is
60 not a valid destination name.
61
62 -m Send mail (see mailx ) after the files have been printed. By
63 default, no mail is sent upon normal completion of the print
64 request.
65
66 -n copies
67 Write copies number of copies of the files, where copies is a
68 positive decimal integer. The methods for producing multiple
69 copies and for arranging the multiple copies when multiple file
70 operands are used are unspecified, except that each file shall
71 be output as an integral whole, not interleaved with portions of
72 other files.
73
74 -o option
75 Specify printer-dependent or class-dependent options. Several
76 such options may be collected by specifying the -o option more
77 than once.
78
79 -s Suppress messages from lp.
80
81 -t title
82 Write title on the banner page of the output.
83
84 -w Write a message on the user's terminal after the files have been
85 printed. If the user is not logged in, then mail shall be sent
86 instead.
87
88
90 The following operand shall be supported:
91
92 file A pathname of a file to be output. If no file operands are spec‐
93 ified, or if a file operand is '-' , the standard input shall be
94 used. If a file operand is used, but the -c option is not speci‐
95 fied, the process performing the writing to the output device
96 may have user and group permissions that differ from that of the
97 process invoking lp.
98
99
101 The standard input shall be used only if no file operands are speci‐
102 fied, or if a file operand is '-' . See the INPUT FILES section.
103
105 The input files shall be text files.
106
108 The following environment variables shall affect the execution of lp:
109
110 LANG Provide a default value for the internationalization variables
111 that are unset or null. (See the Base Definitions volume of
112 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
113 ables for the precedence of internationalization variables used
114 to determine the values of locale categories.)
115
116 LC_ALL If set to a non-empty string value, override the values of all
117 the other internationalization variables.
118
119 LC_CTYPE
120 Determine the locale for the interpretation of sequences of
121 bytes of text data as characters (for example, single-byte as
122 opposed to multi-byte characters in arguments and input files).
123
124 LC_MESSAGES
125 Determine the locale that should be used to affect the format
126 and contents of diagnostic messages written to standard error
127 and informative messages written to standard output.
128
129 LC_TIME
130 Determine the format and contents of date and time strings dis‐
131 played in the lp banner page, if any.
132
133 LPDEST Determine the destination. If the LPDEST environment variable is
134 not set, the PRINTER environment variable shall be used. The -d
135 dest option takes precedence over LPDEST . Results are undefined
136 when -d is not specified and LPDEST contains a value that is not
137 a valid destination name.
138
139 NLSPATH
140 Determine the location of message catalogs for the processing of
141 LC_MESSAGES .
142
143 PRINTER
144 Determine the output device or destination. If the LPDEST and
145 PRINTER environment variables are not set, an unspecified output
146 device is used. The -d dest option and the LPDEST environment
147 variable shall take precedence over PRINTER . Results are unde‐
148 fined when -d is not specified, LPDEST is unset, and PRINTER
149 contains a value that is not a valid device or destination name.
150
151 TZ Determine the timezone used to calculate date and time strings
152 displayed in the lp banner page, if any. If TZ is unset or null,
153 an unspecified default timezone shall be used.
154
155
157 Default.
158
160 The lp utility shall write a request ID to the standard output, unless
161 -s is specified. The format of the message is unspecified. The request
162 ID can be used on systems supporting the historical cancel and lpstat
163 utilities.
164
166 The standard error shall be used only for diagnostic messages.
167
169 None.
170
172 None.
173
175 The following exit values shall be returned:
176
177 0 All input files were processed successfully.
178
179 >0 No output device was available, or an error occurred.
180
181
183 Default.
184
185 The following sections are informative.
186
188 The pr and fold utilities can be used to achieve reasonable formatting
189 for the implementation's default page size.
190
191 A conforming application can use one of the file operands only with the
192 -c option or if the file is publicly readable and guaranteed to be
193 available at the time of printing. This is because IEEE Std 1003.1-2001
194 gives the implementation the freedom to queue up the request for print‐
195 ing at some later time by a different process that might not be able to
196 access the file.
197
199 1. To print file file:
200
201
202 lp -c file
203
204 2. To print multiple files with headers:
205
206
207 pr file1 file2 | lp
208
210 The lp utility was designed to be a basic version of a utility that is
211 already available in many historical implementations. The standard
212 developers considered that it should be implementable simply as:
213
214
215 cat "$@" > /dev/lp
216
217 after appropriate processing of options, if that is how the implementa‐
218 tion chose to do it and if exclusive access could be granted (so that
219 two users did not write to the device simultaneously). Although in the
220 future the standard developers may add other options to this utility,
221 it should always be able to execute with no options or operands and
222 send the standard input to an unspecified output device.
223
224 This volume of IEEE Std 1003.1-2001 makes no representations concerning
225 the format of the printed output, except that it must be "human-read‐
226 able" and "non-volatile". Thus, writing by default to a disk or tape
227 drive or a display terminal would not qualify. (Such destinations are
228 not prohibited when -d dest, LPDEST , or PRINTER are used, however.)
229
230 This volume of IEEE Std 1003.1-2001 is worded such that a "print job"
231 consisting of multiple input files, possibly in multiple copies, is
232 guaranteed to print so that any one file is not intermixed with
233 another, but there is no statement that all the files or copies have to
234 print out together.
235
236 The -c option may imply a spooling operation, but this is not required.
237 The utility can be implemented to wait until the printer is ready and
238 then wait until it is finished. Because of that, there is no attempt to
239 define a queuing mechanism (priorities, classes of output, and so on).
240
241 On some historical systems, the request ID reported on the STDOUT can
242 be used to later cancel or find the status of a request using utilities
243 not defined in this volume of IEEE Std 1003.1-2001.
244
245 Although the historical System V lp and BSD lpr utilities have provided
246 similar functionality, they used different names for the environment
247 variable specifying the destination printer. Since the name of the
248 utility here is lp, LPDEST (used by the System V lp utility) was given
249 precedence over PRINTER (used by the BSD lpr utility). Since environ‐
250 ments of users frequently contain one or the other environment vari‐
251 able, the lp utility is required to recognize both. If this was not
252 done, many applications would send output to unexpected output devices
253 when users moved from system to system.
254
255 Some have commented that lp has far too little functionality to make it
256 worthwhile. Requests have proposed additional options or operands or
257 both that added functionality. The requests included:
258
259 * Wording requiring the output to be "hardcopy"
260
261 * A requirement for multiple printers
262
263 * Options for supporting various page-description languages
264
265 Given that a compliant system is not required to even have a printer,
266 placing further restrictions upon the behavior of the printer is not
267 useful. Since hardcopy format is so application-dependent, it is diffi‐
268 cult, if not impossible, to select a reasonable subset of functionality
269 that should be required on all compliant systems.
270
271 The term unspecified is used in this section in lieu of implementation-
272 defined as most known implementations would not be able to make defini‐
273 tive statements in their conformance documents; the existence and usage
274 of printers is very dependent on how the system administrator config‐
275 ures each individual system.
276
277 Since the default destination, device type, queuing mechanisms, and
278 acceptable forms of input are all unspecified, usage guidelines for
279 what a conforming application can do are as follows:
280
281 * Use the command in a pipeline, or with -c, so that there are no per‐
282 mission problems and the files can be safely deleted or modified.
283
284 * Limit output to text files of reasonable line lengths and printable
285 characters and include no device-specific formatting information,
286 such as a page description language. The meaning of "reasonable" in
287 this context can only be answered as a quality-of-implementation
288 issue, but it should be apparent from historical usage patterns in
289 the industry and the locale. The pr and fold utilities can be used
290 to achieve reasonable formatting for the default page size of the
291 implementation.
292
293 Alternatively, the application can arrange its installation in such a
294 way that it requires the system administrator or operator to provide
295 the appropriate information on lp options and environment variable val‐
296 ues.
297
298 At a minimum, having this utility in this volume of
299 IEEE Std 1003.1-2001 tells the industry that conforming applications
300 require a means to print output and provides at least a command name
301 and LPDEST routing mechanism that can be used for discussions between
302 vendors, application writers, and users. The use of "should" in the
303 DESCRIPTION of lp clearly shows the intent of the standard developers,
304 even if they cannot mandate that all systems (such as laptops) have
305 printers.
306
307 This volume of IEEE Std 1003.1-2001 does not specify what the ownership
308 of the process performing the writing to the output device may be. If
309 -c is not used, it is unspecified whether the process performing the
310 writing to the output device has permission to read file if there are
311 any restrictions in place on who may read file until after it is
312 printed. Also, if -c is not used, the results of deleting file before
313 it is printed are unspecified.
314
316 None.
317
319 mailx
320
322 Portions of this text are reprinted and reproduced in electronic form
323 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
324 -- Portable Operating System Interface (POSIX), The Open Group Base
325 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
326 Electrical and Electronics Engineers, Inc and The Open Group. In the
327 event of any discrepancy between this version and the original IEEE and
328 The Open Group Standard, the original IEEE and The Open Group Standard
329 is the referee document. The original Standard can be obtained online
330 at http://www.opengroup.org/unix/online.html .
331
332
333
334IEEE/The Open Group 2003 LP(P)