589-591.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 116 行
HTML
116 行
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Devices</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=33//-->
<!--PAGES=589-591//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="586-588.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="591-593.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">The /etc/printcap File and Spooling Directories</FONT></H4>
<P>The <TT>/etc/printcap</TT> file is consulted by both the user’s print command <TT>lpr</TT> and the <TT>lpd</TT> print daemon. It contains information about every printer that is accessible from the Linux machine.</P>
<P>The format of <TT>/etc/printcap</TT> is straightforward (and similar to the <TT>/etc/termcap</TT> file for terminal descriptions). The following is an extract from <TT>/etc/printcap</TT>:</P>
<!-- CODE SNIP //-->
<PRE>
# HP Laserjet
lp|hplj|laserjet-acctng|HP LaserJet 4M in Room 425:\
:lp=/dev/lp0:\
:sd=/usr/spool/lp0:\
:lf=/usr/spool/errorlog:\
:mx#0:\
:of=/usr/spool/lp0/hpjlp:\
</PRE>
<!-- END CODE SNIP //-->
<P>The first field in each entry is a list of all the allowable names for the printer. These can be used with the environment variables set by a user’s shell or by the system, as well as with options on the <TT>lpr</TT> command line with a destination printer specified. Valid names are separated by a vertical bar.</P>
<P>Usually, each entry includes at least three names: a short name that is four characters or less (such as <TT>hplj</TT>); a more complete name with an owner, if necessary (such as <TT>laserjet-acctng</TT>); and a full, descriptive name with any other information necessary to identify the printer (such as <TT>HP LaserJet 4M in Room 425</TT>).</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>If a print job is submitted without a destination name, and one can’t be determined from environment variable values, it is routed to the printer <TT>lp</TT>. Therefore, one of the printers (usually the system default printer) should also have the name <TT>lp</TT> as part of its identifier.<HR></FONT>
</BLOCKQUOTE>
<P>A comment in the file is shown with a pound symbol (sometimes called a hash mark) as the first character. Following the printer name is a set of two-character parameters and values used by the printer. The format of these entries is always one of the following:
</P>
<CENTER>
<TABLE WIDTH="90%"><TR>
<TD WIDTH="30%"><TT>NN</TT>
<TD WIDTH="70%">A Boolean value
<TR>
<TD><TT>NN=string</TT>
<TD>Set equal to <TT>string</TT>
<TR>
<TD><TT>NN#number</TT>
<TD>Set not equal to <TT>number</TT>
</TABLE>
</CENTER>
<P>When a Boolean value is used (no assignment follows the two-character identifier), the value is set to True (zero return code) by default. If the value of False (non-zero return code) is required, the two-character identifier will not be included in the description.
</P>
<P>Most assignments are shown with colons beginning and ending each definition to enhance readability and make the file easier for the print utilities to parse. Null values are valid assignments employed by putting two colons together.</P>
<P>A few of the parameters in the <TT>/etc/printcap</TT> file are worth highlighting because they are useful for administration purposes. Not all of these parameters might be present in every printer definition in the <TT>/etc/printcap</TT> file, but most appear:</P>
<CENTER>
<TABLE WIDTH="90%"><TR>
<TD WIDTH="20%"><TT>sd</TT>
<TD WIDTH="80%">The spool directory
<TR>
<TD><TT>lf</TT>
<TD>The log directory for error messages
<TR>
<TD><TT>af</TT>
<TD>Accounting log file
<TR>
<TD><TT>mx</TT>
<TD>Determines the type of files that can be printed
<TR>
<TD><TT>of</TT>
<TD>Output filter program to be used when printing
</TABLE>
</CENTER>
<P>All printers should have their own spool directories, usually under the printer name in <TT>/usr/spool</TT>, such as <TT>/usr/spool/hplj</TT>. Spool directories are necessary for both remote and local printers. When a new printer is added to the system, the spool directory might have to be created manually (using <TT>mkdir</TT>). The permissions for the spool directory should be set to 775. The directory must be owned by <TT>root</TT> or <TT>daemon</TT>. The group ID should be set to <TT>root</TT> or <TT>daemon</TT>, too. In both cases, <TT>daemon</TT> theoretically is the better ID for user and group, although <TT>root</TT> will work also.</P>
<P>The error log file can be located anywhere on the system. It can be shared by all printers, if desired, because each log entry includes the name of the printer.</P>
<P>The accounting log file is used to record printouts for systems in which users are charged. If accounting records are not to be used on the system, ignore the entry entirely in the <TT>/etc/printcap</TT> file. The file can also be used for generating statistics, however. Some heavily used systems may want to have the accounting file for those purposes even when charges are not incurred by the users. An entry is written to the accounting log file after a print job has completed. Account information can be displayed with the Linux <TT>pac</TT> command. (Use the <TT>man pac</TT> command to display the man pages for more information about <TT>pac</TT>.)</P>
<P>The <TT>mx</TT> character enables you to identify the types of files to be printed. Usually this is set to <TT>mx#0</TT>, meaning that there are no restrictions on the types of files.</P>
<P>Output filters modify the format of the outgoing file to the printer to fit its requirements. For example, many laser printers can’t handle 66 lines per page, so the output filter repaginates to 60 lines (or whatever the number of lines per page is set to). Sometimes, special codes must be added to force line feeds, font changes, or paper bin selections. All these items are part of the output filter. Several other types of filters are available, but the output filter is the one most commonly encountered.</P>
<P>Within each spool directory, there may be two status files: <TT>status</TT> and <TT>lock</TT>. Each file is one line long and can be modified with an editor. These files contain a description of the current state of the printer. They are created and managed by the <TT>lpd</TT> printer daemon and used by several printer commands for status information.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="586-588.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="591-593.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?