Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
lp.html (21295B)
1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved --> 2 <!DOCTYPE HTML> 3 <html lang="en"> 4 <head> 5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 --> 8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved --> 9 <title>lp</title> 10 </head> 11 <body bgcolor="white"> 12 <div class="NAVHEADER"> 13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 14 <tr class="nav"> 15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/logname.html" accesskey="P"><<< 16 Previous</a></td> 17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ls.html" accesskey="N">Next >>></a></td> 19 </tr> 20 </table> 21 <hr align="left" width="100%"></div> 22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 23 <center><font size="2">The Open Group Base Specifications Issue 8<br> 24 IEEE Std 1003.1-2024<br> 25 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 26 <hr size="2" noshade> 27 <a name="top" id="top"></a> <a name="lp" id="lp"></a> <a name="tag_20_72" id="tag_20_72"></a><!-- lp --> 28 <h4 class="mansect"><a name="tag_20_72_01" id="tag_20_72_01"></a>NAME</h4> 29 <blockquote>lp — send files to a printer</blockquote> 30 <h4 class="mansect"><a name="tag_20_72_02" id="tag_20_72_02"></a>SYNOPSIS</h4> 31 <blockquote class="synopsis"> 32 <p><code><tt>lp</tt> <b>[</b><tt>-c</tt><b>] [</b><tt>-d</tt> <i>dest</i><b>] [</b><tt>-n</tt> <i>copies</i><b>] [</b><tt>-msw</tt><b>] 33 [</b><tt>-o</tt> <i>option</i><b>]</b><tt>...</tt> <b>[</b><tt>-t</tt> <i>title</i><b>] [</b><i>file</i><tt>...</tt><b>]</b></code></p> 34 </blockquote> 35 <h4 class="mansect"><a name="tag_20_72_03" id="tag_20_72_03"></a>DESCRIPTION</h4> 36 <blockquote> 37 <p>The <i>lp</i> utility shall copy the input files to an output destination in an unspecified manner. The default output 38 destination should be to a hardcopy device, such as a printer or microfilm recorder, that produces non-volatile, human-readable 39 documents. If such a device is not available to the application, or if the system provides no such device, the <i>lp</i> utility 40 shall exit with a non-zero exit status.</p> 41 <p>The actual writing to the output device may occur some time after the <i>lp</i> utility successfully exits. During the portion 42 of the writing that corresponds to each input file, the implementation shall guarantee exclusive access to the device.</p> 43 <p>The <i>lp</i> utility shall associate a unique <i>request ID</i> with each request.</p> 44 <p>Normally, a banner page is produced to separate and identify each print job. This page may be suppressed by 45 implementation-defined conditions, such as an operator command or one of the <b>-o</b> <i>option</i> values.</p> 46 </blockquote> 47 <h4 class="mansect"><a name="tag_20_72_04" id="tag_20_72_04"></a>OPTIONS</h4> 48 <blockquote> 49 <p>The <i>lp</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 50 Guidelines</i></a> .</p> 51 <p>The following options shall be supported:</p> 52 <dl compact> 53 <dd></dd> 54 <dt><b>-c</b></dt> 55 <dd>Exit only after further access to any of the input files is no longer required. The application can then safely delete or 56 modify the files without affecting the output operation. Normally, files are not copied, but are linked whenever possible. If the 57 <b>-c</b> option is not given, then the user should be careful not to remove any of the files before the request has been printed 58 in its entirety. It should also be noted that in the absence of the <b>-c</b> option, any changes made to the named files after the 59 request is made but before it is printed may be reflected in the printed output. On some implementations, <b>-c</b> may be on by 60 default.</dd> 61 <dt><b>-d </b><i>dest</i></dt> 62 <dd>Specify a string that names the destination (<i>dest</i>). If <i>dest</i> is a printer, the request shall be printed only on 63 that specific printer. If <i>dest</i> is a class of printers, the request shall be printed on the first available printer that is a 64 member of the class. Under certain conditions (printer unavailability, file space limitation, and so on), requests for specific 65 destinations need not be accepted. Destination names vary between systems. 66 <p>If <b>-d</b> is not specified, and neither the <i>LPDEST</i> nor <i>PRINTER</i> environment variable is set, an unspecified 67 destination is used. The <b>-d</b> <i>dest</i> option shall take precedence over <i>LPDEST ,</i> which in turn shall take 68 precedence over <i>PRINTER .</i> Results are undefined when <i>dest</i> contains a value that is not a valid destination name.</p> 69 </dd> 70 <dt><b>-m</b></dt> 71 <dd>Send mail (see <a href="../utilities/mailx.html#"><i>mailx</i></a> ) after the files have been printed. By default, no mail is 72 sent upon normal completion of the print request.</dd> 73 <dt><b>-n </b><i>copies</i></dt> 74 <dd>Write <i>copies</i> number of copies of the files, where <i>copies</i> is a positive decimal integer. The methods for producing 75 multiple copies and for arranging the multiple copies when multiple <i>file</i> operands are used are unspecified, except that each 76 file shall be output as an integral whole, not interleaved with portions of other files.</dd> 77 <dt><b>-o </b><i>option</i></dt> 78 <dd>Specify printer-dependent or class-dependent <i>option</i>s. Several such <i>option</i>s may be collected by specifying the 79 <b>-o</b> option more than once.</dd> 80 <dt><b>-s</b></dt> 81 <dd>Suppress messages from <i>lp</i>.</dd> 82 <dt><b>-t </b><i>title</i></dt> 83 <dd>Write <i>title</i> on the banner page of the output.</dd> 84 <dt><b>-w</b></dt> 85 <dd>Write a message on the user's terminal after the files have been printed. If the user is not logged in, then mail shall be sent 86 instead.</dd> 87 </dl> 88 </blockquote> 89 <h4 class="mansect"><a name="tag_20_72_05" id="tag_20_72_05"></a>OPERANDS</h4> 90 <blockquote> 91 <p>The following operand shall be supported:</p> 92 <dl compact> 93 <dd></dd> 94 <dt><i>file</i></dt> 95 <dd>A pathname of a file to be output. If no <i>file</i> operands are specified, or if a <i>file</i> operand is <tt>'-'</tt>, the 96 standard input shall be used. If a <i>file</i> operand is used, but the <b>-c</b> option is not specified, the process performing 97 the writing to the output device may have user and group permissions that differ from that of the process invoking <i>lp</i>.</dd> 98 </dl> 99 </blockquote> 100 <h4 class="mansect"><a name="tag_20_72_06" id="tag_20_72_06"></a>STDIN</h4> 101 <blockquote> 102 <p>The standard input shall be used only if no <i>file</i> operands are specified, or if a <i>file</i> operand is <tt>'-'</tt>. See 103 the INPUT FILES section.</p> 104 </blockquote> 105 <h4 class="mansect"><a name="tag_20_72_07" id="tag_20_72_07"></a>INPUT FILES</h4> 106 <blockquote> 107 <p>The input files shall be text files.</p> 108 </blockquote> 109 <h4 class="mansect"><a name="tag_20_72_08" id="tag_20_72_08"></a>ENVIRONMENT VARIABLES</h4> 110 <blockquote> 111 <p>The following environment variables shall affect the execution of <i>lp</i>:</p> 112 <dl compact> 113 <dd></dd> 114 <dt><i>LANG</i></dt> 115 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 116 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 117 variables used to determine the values of locale categories.)</dd> 118 <dt><i>LC_ALL</i></dt> 119 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 120 <dt><i>LC_CTYPE</i></dt> 121 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 122 opposed to multi-byte characters in arguments and input files).</dd> 123 <dt><i>LC_MESSAGES</i></dt> 124 <dd><br> 125 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and 126 informative messages written to standard output.</dd> 127 <dt><i>LC_TIME</i></dt> 128 <dd>Determine the format and contents of date and time strings displayed in the <i>lp</i> banner page, if any.</dd> 129 <dt><i>LPDEST</i></dt> 130 <dd>Determine the destination. If the <i>LPDEST</i> environment variable is not set, the <i>PRINTER</i> environment variable shall 131 be used. The <b>-d</b> <i>dest</i> option takes precedence over <i>LPDEST .</i> Results are undefined when <b>-d</b> is not 132 specified and <i>LPDEST</i> contains a value that is not a valid destination name.</dd> 133 <dt><i>NLSPATH</i></dt> 134 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 135 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 136 "0"></dd> 137 <dt><i>PRINTER</i></dt> 138 <dd>Determine the output device or destination. If the <i>LPDEST</i> and <i>PRINTER</i> environment variables are not set, an 139 unspecified output device is used. The <b>-d</b> <i>dest</i> option and the <i>LPDEST</i> environment variable shall take 140 precedence over <i>PRINTER .</i> Results are undefined when <b>-d</b> is not specified, <i>LPDEST</i> is unset, and <i>PRINTER</i> 141 contains a value that is not a valid device or destination name.</dd> 142 <dt><i>TZ</i></dt> 143 <dd>Determine the timezone used to calculate date and time strings displayed in the <i>lp</i> banner page, if any. If <i>TZ</i> is 144 unset or null, an unspecified default timezone shall be used.</dd> 145 </dl> 146 </blockquote> 147 <h4 class="mansect"><a name="tag_20_72_09" id="tag_20_72_09"></a>ASYNCHRONOUS EVENTS</h4> 148 <blockquote> 149 <p>Default.</p> 150 </blockquote> 151 <h4 class="mansect"><a name="tag_20_72_10" id="tag_20_72_10"></a>STDOUT</h4> 152 <blockquote> 153 <p>The <i>lp</i> utility shall write a <i>request ID</i> to the standard output, unless <b>-s</b> is specified. The format of the 154 message is unspecified. The request ID can be used on systems supporting the historical <i>cancel</i> and <i>lpstat</i> 155 utilities.</p> 156 </blockquote> 157 <h4 class="mansect"><a name="tag_20_72_11" id="tag_20_72_11"></a>STDERR</h4> 158 <blockquote> 159 <p>The standard error shall be used only for diagnostic messages.</p> 160 </blockquote> 161 <h4 class="mansect"><a name="tag_20_72_12" id="tag_20_72_12"></a>OUTPUT FILES</h4> 162 <blockquote> 163 <p>None.</p> 164 </blockquote> 165 <h4 class="mansect"><a name="tag_20_72_13" id="tag_20_72_13"></a>EXTENDED DESCRIPTION</h4> 166 <blockquote> 167 <p>None.</p> 168 </blockquote> 169 <h4 class="mansect"><a name="tag_20_72_14" id="tag_20_72_14"></a>EXIT STATUS</h4> 170 <blockquote> 171 <p>The following exit values shall be returned:</p> 172 <dl compact> 173 <dd></dd> 174 <dt> 0</dt> 175 <dd>All input files were processed successfully.</dd> 176 <dt>>0</dt> 177 <dd>No output device was available, or an error occurred.</dd> 178 </dl> 179 </blockquote> 180 <h4 class="mansect"><a name="tag_20_72_15" id="tag_20_72_15"></a>CONSEQUENCES OF ERRORS</h4> 181 <blockquote> 182 <p>Default.</p> 183 </blockquote> 184 <hr> 185 <div class="box"><em>The following sections are informative.</em></div> 186 <h4 class="mansect"><a name="tag_20_72_16" id="tag_20_72_16"></a>APPLICATION USAGE</h4> 187 <blockquote> 188 <p>The <a href="../utilities/pr.html"><i>pr</i></a> and <a href="../utilities/fold.html"><i>fold</i></a> utilities can be used to 189 achieve reasonable formatting for the implementation's default page size.</p> 190 <p>A conforming application can use one of the <i>file</i> operands only with the <b>-c</b> option or if the file is publicly 191 readable and guaranteed to be available at the time of printing. This is because POSIX.1-2024 gives the implementation the freedom 192 to queue up the request for printing at some later time by a different process that might not be able to access the file.</p> 193 </blockquote> 194 <h4 class="mansect"><a name="tag_20_72_17" id="tag_20_72_17"></a>EXAMPLES</h4> 195 <blockquote> 196 <ol> 197 <li> 198 <p>To print file <i>file</i>:</p> 199 <pre> 200 <tt>lp -c </tt><i>file</i><tt> 201 </tt></pre></li> 202 <li> 203 <p>To print multiple files with headers:</p> 204 <pre> 205 <tt>pr </tt><i>file1 file2</i><tt> | lp 206 </tt></pre></li> 207 </ol> 208 </blockquote> 209 <h4 class="mansect"><a name="tag_20_72_18" id="tag_20_72_18"></a>RATIONALE</h4> 210 <blockquote> 211 <p>The <i>lp</i> utility was designed to be a basic version of a utility that is already available in many historical 212 implementations. The standard developers considered that it should be implementable simply as:</p> 213 <pre> 214 <tt>cat "$@" > /dev/lp 215 </tt></pre> 216 <p>after appropriate processing of options, if that is how the implementation chose to do it and if exclusive access could be 217 granted (so that two users did not write to the device simultaneously). Although in the future the standard developers may add 218 other options to this utility, it should always be able to execute with no options or operands and send the standard input to an 219 unspecified output device.</p> 220 <p>This volume of POSIX.1-2024 makes no representations concerning the format of the printed output, except that it must be 221 "human-readable" and "non-volatile". Thus, writing by default to a disk or tape drive or a display terminal would not qualify. 222 (Such destinations are not prohibited when <b>-d</b> <i>dest</i>, <i>LPDEST ,</i> or <i>PRINTER</i> are used, however.)</p> 223 <p>This volume of POSIX.1-2024 is worded such that a "print job" consisting of multiple input files, possibly in multiple copies, 224 is guaranteed to print so that any one file is not intermixed with another, but there is no statement that all the files or copies 225 have to print out together.</p> 226 <p>The <b>-c</b> option may imply a spooling operation, but this is not required. The utility can be implemented to wait until the 227 printer is ready and then wait until it is finished. Because of that, there is no attempt to define a queuing mechanism 228 (priorities, classes of output, and so on).</p> 229 <p>On some historical systems, the request ID reported on the STDOUT can be used to later cancel or find the status of a request 230 using utilities not defined in this volume of POSIX.1-2024.</p> 231 <p>Although the historical System V <i>lp</i> and BSD <i>lpr</i> utilities have provided similar functionality, they used different 232 names for the environment variable specifying the destination printer. Since the name of the utility here is <i>lp</i>, 233 <i>LPDEST</i> (used by the System V <i>lp</i> utility) was given precedence over <i>PRINTER</i> (used by the BSD <i>lpr</i> 234 utility). Since environments of users frequently contain one or the other environment variable, the <i>lp</i> utility is required 235 to recognize both. If this was not done, many applications would send output to unexpected output devices when users moved from 236 system to system.</p> 237 <p>Some have commented that <i>lp</i> has far too little functionality to make it worthwhile. Requests have proposed additional 238 options or operands or both that added functionality. The requests included:</p> 239 <ul> 240 <li> 241 <p>Wording <i>requiring</i> the output to be "hardcopy"</p> 242 </li> 243 <li> 244 <p>A requirement for multiple printers</p> 245 </li> 246 <li> 247 <p>Options for supporting various page-description languages</p> 248 </li> 249 </ul> 250 <p>Given that a compliant system is not required to even have a printer, placing further restrictions upon the behavior of the 251 printer is not useful. Since hardcopy format is so application-dependent, it is difficult, if not impossible, to select a 252 reasonable subset of functionality that should be required on all compliant systems.</p> 253 <p>The term <i>unspecified</i> is used in this section in lieu of <i>implementation-defined</i> as most known implementations would 254 not be able to make definitive statements in their conformance documents; the existence and usage of printers is very dependent on 255 how the system administrator configures each individual system.</p> 256 <p>Since the default destination, device type, queuing mechanisms, and acceptable forms of input are all unspecified, usage 257 guidelines for what a conforming application can do are as follows:</p> 258 <ul> 259 <li> 260 <p>Use the command in a pipeline, or with <b>-c</b>, so that there are no permission problems and the files can be safely deleted 261 or modified.</p> 262 </li> 263 <li> 264 <p>Limit output to text files of reasonable line lengths and printable characters and include no device-specific formatting 265 information, such as a page description language. The meaning of "reasonable" in this context can only be answered as a 266 quality-of-implementation issue, but it should be apparent from historical usage patterns in the industry and the locale. The 267 <a href="../utilities/pr.html"><i>pr</i></a> and <a href="../utilities/fold.html"><i>fold</i></a> utilities can be used to achieve 268 reasonable formatting for the default page size of the implementation.</p> 269 </li> 270 </ul> 271 <p>Alternatively, the application can arrange its installation in such a way that it requires the system administrator or operator 272 to provide the appropriate information on <i>lp</i> options and environment variable values.</p> 273 <p>At a minimum, having this utility in this volume of POSIX.1-2024 tells the industry that conforming applications require a means 274 to print output and provides at least a command name and <i>LPDEST</i> routing mechanism that can be used for discussions between 275 vendors, application developers, and users. The use of "should" in the DESCRIPTION of <i>lp</i> clearly shows the intent of the 276 standard developers, even if they cannot mandate that all systems (such as laptops) have printers.</p> 277 <p>This volume of POSIX.1-2024 does not specify what the ownership of the process performing the writing to the output device may 278 be. If <b>-c</b> is not used, it is unspecified whether the process performing the writing to the output device has permission to 279 read <i>file</i> if there are any restrictions in place on who may read <i>file</i> until after it is printed. Also, if <b>-c</b> 280 is not used, the results of deleting <i>file</i> before it is printed are unspecified.</p> 281 </blockquote> 282 <h4 class="mansect"><a name="tag_20_72_19" id="tag_20_72_19"></a>FUTURE DIRECTIONS</h4> 283 <blockquote> 284 <p>None.</p> 285 </blockquote> 286 <h4 class="mansect"><a name="tag_20_72_20" id="tag_20_72_20"></a>SEE ALSO</h4> 287 <blockquote> 288 <p><a href="../utilities/mailx.html#"><i>mailx</i></a></p> 289 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href= 290 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 291 </blockquote> 292 <h4 class="mansect"><a name="tag_20_72_21" id="tag_20_72_21"></a>CHANGE HISTORY</h4> 293 <blockquote> 294 <p>First released in Issue 2.</p> 295 </blockquote> 296 <h4 class="mansect"><a name="tag_20_72_22" id="tag_20_72_22"></a>Issue 6</h4> 297 <blockquote> 298 <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p> 299 <ul> 300 <li> 301 <p>In the DESCRIPTION, the requirement to associate a unique request ID, and the normal generation of a banner page is added.</p> 302 </li> 303 <li> 304 <p>In the OPTIONS section:</p> 305 <ul> 306 <li> 307 <p>The <b>-d</b> <i>dest</i> description is expanded, but references to <i>lpstat</i> are removed.</p> 308 </li> 309 <li> 310 <p>The <b>-m</b>, <b>-o</b>, <b>-s</b>, <b>-t</b>, and <b>-w</b> options are added.</p> 311 </li> 312 </ul> 313 </li> 314 <li> 315 <p>In the ENVIRONMENT VARIABLES section, <i>LC_TIME</i> may now affect the execution.</p> 316 </li> 317 <li> 318 <p>The STDOUT section is added.</p> 319 </li> 320 </ul> 321 <p>The normative text is reworded to avoid use of the term "must" for application requirements.</p> 322 <p>The <i>TZ</i> entry is added to the ENVIRONMENT VARIABLES section.</p> 323 </blockquote> 324 <h4 class="mansect"><a name="tag_20_72_23" id="tag_20_72_23"></a>Issue 7</h4> 325 <blockquote> 326 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 327 </blockquote> 328 <h4 class="mansect"><a name="tag_20_72_24" id="tag_20_72_24"></a>Issue 8</h4> 329 <blockquote> 330 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 331 </blockquote> 332 <div class="box"><em>End of informative text.</em></div> 333 <hr> 334 <p> </p> 335 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 336 <hr size="2" noshade> 337 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 338 POSIX™ is a Trademark of The IEEE.<br> 339 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 340 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 341 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 342 ]</font></center> 343 <hr size="2" noshade> 344 <div class="NAVHEADER"> 345 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 346 <tr class="nav"> 347 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/logname.html" accesskey="P"><<< 348 Previous</a></td> 349 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 350 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ls.html" accesskey="N">Next >>></a></td> 351 </tr> 352 </table> 353 <hr align="left" width="100%"></div> 354 </body> 355 </html>