1LP(1P)                     POSIX Programmer's Manual                    LP(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       lp — send files to a printer
13

SYNOPSIS

15       lp [-c] [-d dest] [-n copies] [-msw] [-o option]... [-t title] [file...]
16

DESCRIPTION

18       The lp utility shall copy the input files to an output  destination  in
19       an  unspecified  manner.  The default output destination should be to a
20       hardcopy device, such as a printer or microfilm recorder, that produces
21       non-volatile,  human-readable documents. If such a device is not avail‐
22       able to the application, or if the system provides no such device,  the
23       lp utility shall exit with a non-zero exit status.
24
25       The  actual  writing to the output device may occur some time after the
26       lp utility successfully exits. During the portion of the  writing  that
27       corresponds  to  each  input  file,  the implementation shall guarantee
28       exclusive access to the device.
29
30       The lp utility shall associate a unique request ID with each request.
31
32       Normally, a banner page is produced to separate and identify each print
33       job.  This page may be suppressed by implementation-defined conditions,
34       such as an operator command or one of the -o option values.
35

OPTIONS

37       The lp  utility  shall  conform  to  the  Base  Definitions  volume  of
38       POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
39
40       The following options shall be supported:
41
42       -c        Exit  only  after further access to any of the input files is
43                 no longer required. The application can then safely delete or
44                 modify the files without affecting the output operation. Nor‐
45                 mally, files are not copied, but are linked  whenever  possi‐
46                 ble.  If  the -c option is not given, then the user should be
47                 careful not to remove any of the files before the request has
48                 been printed in its entirety. It should also be noted that in
49                 the absence of the -c option, any changes made to  the  named
50                 files  after the request is made but before it is printed may
51                 be reflected in the printed output.  On some implementations,
52                 -c may be on by default.
53
54       -d dest   Specify  a string that names the destination (dest).  If dest
55                 is a printer, the request shall be printed only on that  spe‐
56                 cific  printer.  If  dest is a class of printers, the request
57                 shall be printed on the first available  printer  that  is  a
58                 member  of  the  class.  Under  certain  conditions  (printer
59                 unavailability, file space limitation, and so  on),  requests
60                 for  specific  destinations need not be accepted. Destination
61                 names vary between systems.
62
63                 If -d is not specified, and neither the  LPDEST  nor  PRINTER
64                 environment  variable  is  set, an unspecified destination is
65                 used. The -d dest option shall take precedence  over  LPDEST,
66                 which  in  turn  shall take precedence over PRINTER.  Results
67                 are undefined when dest contains a value that is not a  valid
68                 destination name.
69
70       -m        Send  mail  (see mailx) after the files have been printed. By
71                 default, no mail is sent upon normal completion of the  print
72                 request.
73
74       -n copies Write copies number of copies of the files, where copies is a
75                 positive decimal integer. The methods for producing  multiple
76                 copies  and  for  arranging the multiple copies when multiple
77                 file operands are used are unspecified, except that each file
78                 shall  be  output  as an integral whole, not interleaved with
79                 portions of other files.
80
81       -o option Specify printer-dependent or class-dependent  options.   Sev‐
82                 eral  such  options  may  be  collected  by specifying the -o
83                 option more than once.
84
85       -s        Suppress messages from lp.
86
87       -t title  Write title on the banner page of the output.
88
89       -w        Write a message on the user's terminal after the  files  have
90                 been  printed.  If the user is not logged in, then mail shall
91                 be sent instead.
92

OPERANDS

94       The following operand shall be supported:
95
96       file      A pathname of a file to be output. If no  file  operands  are
97                 specified,  or  if  a file operand is '-', the standard input
98                 shall be used. If a file operand is used, but the  -c  option
99                 is  not  specified, the process performing the writing to the
100                 output device may have user and group permissions that differ
101                 from that of the process invoking lp.
102

STDIN

104       The  standard  input  shall be used only if no file operands are speci‐
105       fied, or if a file operand is '-'.  See the INPUT FILES section.
106

INPUT FILES

108       The input files shall be text files.
109

ENVIRONMENT VARIABLES

111       The following environment variables shall affect the execution of lp:
112
113       LANG      Provide a default value for  the  internationalization  vari‐
114                 ables  that are unset or null. (See the Base Definitions vol‐
115                 ume of POSIX.1‐2017, Section 8.2, Internationalization  Vari‐
116                 ables  for  the  precedence of internationalization variables
117                 used to determine the values of locale categories.)
118
119       LC_ALL    If set to a non-empty string value, override  the  values  of
120                 all the other internationalization variables.
121
122       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
123                 bytes of text data as characters (for example, single-byte as
124                 opposed  to  multi-byte  characters  in  arguments  and input
125                 files).
126
127       LC_MESSAGES
128                 Determine the locale that should be used to affect the format
129                 and contents of diagnostic messages written to standard error
130                 and informative messages written to standard output.
131
132       LC_TIME   Determine the format and contents of date  and  time  strings
133                 displayed in the lp banner page, if any.
134
135       LPDEST    Determine the destination. If the LPDEST environment variable
136                 is not set, the PRINTER environment variable shall  be  used.
137                 The -d dest option takes precedence over LPDEST.  Results are
138                 undefined when -d is not  specified  and  LPDEST  contains  a
139                 value that is not a valid destination name.
140
141       NLSPATH   Determine the location of message catalogs for the processing
142                 of LC_MESSAGES.
143
144       PRINTER   Determine the output device or destination. If the LPDEST and
145                 PRINTER  environment  variables  are  not set, an unspecified
146                 output device is used. The -d  dest  option  and  the  LPDEST
147                 environment  variable  shall  take  precedence  over PRINTER.
148                 Results are undefined when -d is  not  specified,  LPDEST  is
149                 unset,  and  PRINTER  contains  a  value  that is not a valid
150                 device or destination name.
151
152       TZ        Determine the  timezone  used  to  calculate  date  and  time
153                 strings  displayed  in  the  lp banner page, if any. If TZ is
154                 unset or null, an unspecified default timezone shall be used.
155

ASYNCHRONOUS EVENTS

157       Default.
158

STDOUT

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

STDERR

166       The standard error shall be used only for diagnostic messages.
167

OUTPUT FILES

169       None.
170

EXTENDED DESCRIPTION

172       None.
173

EXIT STATUS

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

CONSEQUENCES OF ERRORS

182       Default.
183
184       The following sections are informative.
185

APPLICATION USAGE

187       The  pr and fold utilities can be used to achieve reasonable formatting
188       for the implementation's default page size.
189
190       A conforming application can use one of the file operands only with the
191       -c  option  or  if  the  file is publicly readable and guaranteed to be
192       available at the time of printing. This is because  POSIX.1‐2008  gives
193       the  implementation the freedom to queue up the request for printing at
194       some later time by a different process that might not be able to access
195       the file.
196

EXAMPLES

198        1. To print file file:
199
200
201               lp -c file
202
203        2. To print multiple files with headers:
204
205
206               pr file1 file2 | lp
207

RATIONALE

209       The  lp utility was designed to be a basic version of a utility that is
210       already available in  many  historical  implementations.  The  standard
211       developers considered that it should be implementable simply as:
212
213
214           cat "$@" > /dev/lp
215
216       after appropriate processing of options, if that is how the implementa‐
217       tion chose to do it and if exclusive access could be granted  (so  that
218       two users did not write to the device simultaneously).  Although in the
219       future the standard developers may add other options to  this  utility,
220       it  should  always  be  able to execute with no options or operands and
221       send the standard input to an unspecified output device.
222
223       This volume of POSIX.1‐2017 makes  no  representations  concerning  the
224       format of the printed output, except that it must be ``human-readable''
225       and ``non-volatile''.  Thus, writing by default to a disk or tape drive
226       or  a  display  terminal  would not qualify. (Such destinations are not
227       prohibited when -d dest, LPDEST, or PRINTER are used, however.)
228
229       This volume of POSIX.1‐2017 is worded such that a  ``print  job''  con‐
230       sisting  of multiple input files, possibly in multiple copies, is guar‐
231       anteed to print so that any one file is not  intermixed  with  another,
232       but  there  is  no statement that all the files or copies have to print
233       out together.
234
235       The -c option may imply a spooling operation, but this is not required.
236       The  utility  can be implemented to wait until the printer is ready and
237       then wait until it is finished. Because of that, there is no attempt to
238       define a queuing mechanism (priorities, classes of output, and so on).
239
240       On  some  historical systems, the request ID reported on the STDOUT can
241       be used to later cancel or find the status of a request using utilities
242       not defined in this volume of POSIX.1‐2017.
243
244       Although the historical System V lp and BSD lpr utilities have provided
245       similar functionality, they used different names  for  the  environment
246       variable  specifying  the  destination  printer.  Since the name of the
247       utility here is lp, LPDEST (used by the System V lp utility) was  given
248       precedence  over  PRINTER (used by the BSD lpr utility). Since environ‐
249       ments of users frequently contain one or the  other  environment  vari‐
250       able,  the  lp  utility  is required to recognize both. If this was not
251       done, many applications would send output to unexpected output  devices
252       when users moved from system to system.
253
254       Some have commented that lp has far too little functionality to make it
255       worthwhile. Requests have proposed additional options  or  operands  or
256       both that added functionality. The requests included:
257
258        *  Wording requiring the output to be ``hardcopy''
259
260        *  A requirement for multiple printers
261
262        *  Options for supporting various page-description languages
263
264       Given  that  a compliant system is not required to even have a printer,
265       placing further restrictions upon the behavior of the  printer  is  not
266       useful. Since hardcopy format is so application-dependent, it is diffi‐
267       cult, if not impossible, to select a reasonable subset of functionality
268       that should be required on all compliant systems.
269
270       The term unspecified is used in this section in lieu of implementation-
271       defined as most known implementations would not be able to make defini‐
272       tive statements in their conformance documents; the existence and usage
273       of printers is very dependent on how the system  administrator  config‐
274       ures each individual system.
275
276       Since  the  default  destination,  device type, queuing mechanisms, and
277       acceptable forms of input are all  unspecified,  usage  guidelines  for
278       what a conforming application can do are as follows:
279
280        *  Use  the  command  in  a pipeline, or with -c, so that there are no
281           permission problems and the files can be safely  deleted  or  modi‐
282           fied.
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''
287           in 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 POSIX.1‐2017 tells
299       the industry that conforming applications require a means to print out‐
300       put  and  provides at least a command name and LPDEST routing mechanism
301       that can be used for discussions between vendors, application  develop‐
302       ers,  and users. The use of ``should'' in the DESCRIPTION of lp clearly
303       shows the intent of the standard developers, even if they  cannot  man‐
304       date that all systems (such as laptops) have printers.
305
306       This  volume of POSIX.1‐2017 does not specify what the ownership of the
307       process performing the writing to the output device may be.  If  -c  is
308       not  used, it is unspecified whether the process performing the writing
309       to the output device has permission to  read  file  if  there  are  any
310       restrictions  in  place on who may read file until after it is printed.
311       Also, if -c is not used, the results of  deleting  file  before  it  is
312       printed are unspecified.
313

FUTURE DIRECTIONS

315       None.
316

SEE ALSO

318       mailx
319
320       The  Base  Definitions  volume  of POSIX.1‐2017, Chapter 8, Environment
321       Variables, Section 12.2, Utility Syntax Guidelines
322
324       Portions of this text are reprinted and reproduced in  electronic  form
325       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
326       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
327       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
328       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
329       event of any discrepancy between this version and the original IEEE and
330       The Open Group Standard, the original IEEE and The Open Group  Standard
331       is  the  referee document. The original Standard can be obtained online
332       at http://www.opengroup.org/unix/online.html .
333
334       Any typographical or formatting errors that appear  in  this  page  are
335       most likely to have been introduced during the conversion of the source
336       files to man page format. To report such errors,  see  https://www.ker
337       nel.org/doc/man-pages/reporting_bugs.html .
338
339
340
341IEEE/The Open Group                  2017                               LP(1P)
Impressum