📄 lp.html
字号:
<blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>All input files were processed successfully.</dd><dt>>0</dt><dd>No output device was available, or an error occurred.</dd></dl></blockquote><h4><a name="tag_04_80_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_80_16"></a>APPLICATION USAGE</h4><blockquote><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 toachieve reasonable formatting for the implementation's default page size.</p><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 publiclyreadable and guaranteed to be available at the time of printing. This is because IEEE Std 1003.1-2001 gives theimplementation the freedom to queue up the request for printing at some later time by a different process that might not be able toaccess the file.</p></blockquote><h4><a name="tag_04_80_17"></a>EXAMPLES</h4><blockquote><ol><li><p>To print file <i>file</i>:</p><pre><tt>lp -c</tt> <i>file</i></pre></li><li><p>To print multiple files with headers:</p><pre><tt>pr</tt> <i>file1 file2</i> <tt>| lp</tt></pre></li></ol></blockquote><h4><a name="tag_04_80_18"></a>RATIONALE</h4><blockquote><p>The <i>lp</i> utility was designed to be a basic version of a utility that is already available in many historicalimplementations. The standard developers considered that it should be implementable simply as:</p><pre><tt>cat "$@" > /dev/lp</tt></pre><p>after appropriate processing of options, if that is how the implementation chose to do it and if exclusive access could begranted (so that two users did not write to the device simultaneously). Although in the future the standard developers may addother options to this utility, it should always be able to execute with no options or operands and send the standard input to anunspecified output device.</p><p>This volume of IEEE Std 1003.1-2001 makes no representations concerning the format of the printed output, except thatit must be "human-readable" and "non-volatile". Thus, writing by default to a disk or tape drive or a display terminal wouldnot qualify. (Such destinations are not prohibited when <b>-d</b> <i>dest</i>, <i>LPDEST ,</i> or <i>PRINTER</i> are used,however.)</p><p>This volume of IEEE Std 1003.1-2001 is worded such that a "print job" consisting of multiple input files, possiblyin multiple copies, is guaranteed to print so that any one file is not intermixed with another, but there is no statement that allthe files or copies have to print out together.</p><p>The <b>-c</b> option may imply a spooling operation, but this is not required. The utility can be implemented to wait until theprinter is ready and then wait until it is finished. Because of that, there is no attempt to define a queuing mechanism(priorities, classes of output, and so on).</p><p>On some historical systems, the request ID reported on the STDOUT can be used to later cancel or find the status of a requestusing utilities not defined in this volume of IEEE Std 1003.1-2001.</p><p>Although the historical System V <i>lp</i> and BSD <i>lpr</i> utilities have provided similar functionality, they used differentnames for the environment variable specifying the destination printer. Since the name of the utility here is <i>lp</i>,<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>utility). Since environments of users frequently contain one or the other environment variable, the <i>lp</i> utility is requiredto recognize both. If this was not done, many applications would send output to unexpected output devices when users moved fromsystem to system.</p><p>Some have commented that <i>lp</i> has far too little functionality to make it worthwhile. Requests have proposed additionaloptions or operands or both that added functionality. The requests included:</p><ul><li><p>Wording <i>requiring</i> the output to be "hardcopy"</p></li><li><p>A requirement for multiple printers</p></li><li><p>Options for supporting various page-description languages</p></li></ul><p>Given that a compliant system is not required to even have a printer, placing further restrictions upon the behavior of theprinter is not useful. Since hardcopy format is so application-dependent, it is difficult, if not impossible, to select areasonable subset of functionality that should be required on all compliant systems.</p><p>The term <i>unspecified</i> is used in this section in lieu of <i>implementation-defined</i> as most known implementations wouldnot be able to make definitive statements in their conformance documents; the existence and usage of printers is very dependent onhow the system administrator configures each individual system.</p><p>Since the default destination, device type, queuing mechanisms, and acceptable forms of input are all unspecified, usageguidelines for what a conforming application can do are as follows:</p><ul><li><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 deletedor modified.</p></li><li><p>Limit output to text files of reasonable line lengths and printable characters and include no device-specific formattinginformation, such as a page description language. The meaning of "reasonable" in this context can only be answered as aquality-of-implementation issue, but it should be apparent from historical usage patterns in the industry and the locale. The <ahref="../utilities/pr.html"><i>pr</i></a> and <a href="../utilities/fold.html"><i>fold</i></a> utilities can be used to achievereasonable formatting for the default page size of the implementation.</p></li></ul><p>Alternatively, the application can arrange its installation in such a way that it requires the system administrator or operatorto provide the appropriate information on <i>lp</i> options and environment variable values.</p><p>At a minimum, having this utility in this volume of IEEE Std 1003.1-2001 tells the industry that conformingapplications require a means to print output and provides at least a command name and <i>LPDEST</i> routing mechanism that can beused for discussions between vendors, application writers, and users. The use of "should" in the DESCRIPTION of <i>lp</i> clearlyshows the intent of the standard developers, even if they cannot mandate that all systems (such as laptops) have printers.</p><p>This volume of IEEE Std 1003.1-2001 does not specify what the ownership of the process performing the writing to theoutput device may be. If <b>-c</b> is not used, it is unspecified whether the process performing the writing to the output devicehas permission to 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> is not used, the results of deleting <i>file</i> before it is printed are unspecified.</p></blockquote><h4><a name="tag_04_80_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_80_20"></a>SEE ALSO</h4><blockquote><p><a href="mailx.html"><i>mailx</i></a></p></blockquote><h4><a name="tag_04_80_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_80_22"></a>Issue 6</h4><blockquote><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>In the DESCRIPTION, the requirement to associate a unique request ID, and the normal generation of a banner page is added.</p></li><li><p>In the OPTIONS section:</p><ul><li><p>The <b>-d</b> <i>dest</i> description is expanded, but references to <i>lpstat</i> are removed.</p></li><li><p>The <b>-m</b>, <b>-o</b>, <b>-s</b>, <b>-t</b>, and <b>-w</b> options are added.</p></li></ul></li><li><p>In the ENVIRONMENT VARIABLES section, <i>LC_TIME</i> may now affect the execution.</p></li><li><p>The STDOUT section is added.</p></li></ul><p>The normative text is reworded to avoid use of the term "must" for application requirements.</p><p>The <i>TZ</i> entry is added to the ENVIRONMENT VARIABLES section.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -