0233-0235.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 354 行
HTML
354 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Printing with Linux</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=12 //-->
<!-- PAGES=0229-0242 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0229-0232.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0236-0239.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-233"><P>Page 233</P></A>
<UL>
<LI> The hostname of the remote machine hosting the printer
<LI> The printer queue name of the printer on the remote machine
</UL>
<P>This means that you can send documents to other printers anywhere. Using Red Hat's
printtool command to set up remote printing will create a remote printer entry in
/etc/printcap. For details about a remote printer entry, see the
printcap man page and look for the rm and rp capabilities. But you should also know there are other, possibly easier ways to print to
remote printers, such as using the rlpr command. For more
information, read Grant Taylor's Linux Printing HOWTO under
/usr/doc.
</P>
<P>To set up a LAN printer, you'll need the following (according to
printtool):
</P>
<UL>
<LI> Printer server name
<LI> Printer server IP number
<LI> Printer name
<LI> Printer user
<LI> Printer password
</UL>
<P>This information is entered in a dialog that pops up after you select the type of printer
you want to set up. If you want detailed instructions on how to print from Red Hat Linux to
a printer on a Windows 95 system or to print on a Linux printer from Windows 95,
browse to
<a href="http://www.redhat.com/support/docs/rhl/tips.">http://www.redhat.com/support/docs/rhl/Tips.</A>
</P>
<H4><A NAME="ch12_ 7">
Local Printers
</A></H4>
<P>For now, I'll assume you're going to set up a parallel port printer attached directly to
your computer. To do so, run printtool, then click the Add button, select Local, and then click
the OK button.
</P>
<P>An Info dialog will appear, telling you which parallel printer devices have been detected.
Click OK and then click the Select button in the Edit Local Printer Entry dialog. You'll be
presented a large dialog called Configure Filter, with a list of 32 popular printers to choose from
(see Figure 12.2). Pick your printer, or a printer close to yours, and then click the OK button.
</P>
<P>The dialog will disappear, and you can then click OK on the Edit Local Printer Entry
dialog. The printer you defined will appear under the list of Printer Queues in the main
printtool dialog. Select it and then select an ASCII or PostScript test from the Tests menu.
</P>
<P>The ASCII test page prints two lines of text, followed by a centered paragraph of text.
The PostScript test page prints a half-inch and one-inch border, a logo, and color scale
(grayscale on a black-and-white printer).
</P>
<P>printtool works by first defining your printer and then inserting the definition, along with
a pointer to a filter script (written in bash) in the
/var/spool/lpd directory, into an /etc/printcap entry. The filter and associated scripts reside in a directory, or printer queue, under
/var/spool/lpd, with either a name you choose, or an assigned default, such as
lp0. See the sample /etc/printcap database file later in this chapter.
</P>
<A NAME="PAGENUM-234"><P>Page 234</P></A>
<BR>
Figure 12.2.<BR>
The Configure Filter<BR>
dialog.<BR>
<a href="10rhu02.html"><img src="images/tn_10rhu02_jpg.jpg"></a><BR>
<P>You can use printtool to add, edit, or delete different printers. Another nice feature is the
ability to assign a size limit to spooled files, which can be helpful if you have limited disk space
or don't want users to fill up your filesystem. If you have a printer that requires you to change
the print cartridge in order to print black-and-white or color pages, you'll find
printtool indispensable. Try it!
</P>
<P>By the way, although the current version of
printtool, 3.2, creates a backup of your
/etc/printcap database each time you make a change, it does not delete the associated printer
queue, or spool directory, when you delete a printer. One disconcerting
printtool bug is that while you're printing, at least with a kernel using polling, your printer's parallel port will not be
detected if you run printtool to install a printer.
Perhaps this will be fixed in a newer version.
</P>
<H3><A NAME="ch12_ 8">
Linux Printing Commands
</A></H3>
<P>Of course, you don't have to use the printtool command to set up your printer. You can
edit /etc/printcap directly, but you should know what you're doing and understand
printcap's format. This file, an ASCII database of your system's local and networked printers,
describes the capabilities of each printer in detail. For full details, see the
printcap man page for commands, and the termcap man page for the file's layout.
</P>
<P>In fact, you can have multiple entries for each printer, which is helpful is you want to
print different size papers, print color or black-and-white documents, or change printer trays.
</P>
<P>Linux uses the 4.3BSD line printer spooling system. This system has a number of features
and associated programs to support background printing, multiple local and networked
printers, and control of the printers and queued documents.
</P>
<P>The main files used in the Linux printer spooling system are as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
/etc/printcap
/usr/sbin/lpd
/usr/sbin/lpc
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-235"><P>Page 235</P></A>
<!-- CODE SNIP //-->
<PRE>
/usr/bin/lpr
/usr/bin/lprm
/usr/bin/lpq
/dev/printer
</PRE>
<!-- END CODE SNIP //-->
<P>When you first boot Linux, the shell script
lpd.init, under /etc/rc.d/init.d/, starts lpd, the printer daemon. This program, a printer server, runs in the background, waiting for print
requests. When a request is detected (on
/dev/printer), a copy of lpd is created, while the
original continues to wait for more requests.
</P>
<P>Print requests are started with the lpr command. For example, the command
line
</P>
<!-- CODE SNIP //-->
<PRE>
# lpr myfile.txt
</PRE>
<!-- END CODE SNIP //-->
<P>will print your document to a file in the
/var/spool/ directory. There are also print
spooling commands to help you track your request. If you're printing a large document, or a number
of smaller files, you can see a list of print jobs running by using the
lpq command. For example, to print a number of files at once, use
</P>
<!-- CODE SNIP //-->
<PRE>
# lpr .x*
</PRE>
<!-- END CODE SNIP //-->
<P>followed by
</P>
<!-- CODE SNIP //-->
<PRE>
# lpq
</PRE>
<!-- END CODE SNIP //-->
<P>This outputs the following:
</P>
<!-- CODE SNIP //-->
<PRE>
Rank Owner Job Files Total Size
active root 301 .xboing-scores, .xinitrc 1366 bytes
</PRE>
<!-- END CODE SNIP //-->
<P>If you want to stop the preceding print job, use the
lprm command, followed by the job number, as in the following:
</P>
<!-- CODE SNIP //-->
<PRE>
# lprm 301
dfA071Aa01088 dequeued
dfB071Aa01088 dequeued
cfA071Aa01088 dequeued
</PRE>
<!-- END CODE SNIP //-->
<P>This shows that lprm has removed the spool files from the printer's spool directory under
/var/spool/lpd.
</P>
<P>If you want to disable or enable a printer and its spooling queue, rearrange the order of
any print jobs, or find out the status of printers, you can use
lpc from the command line or interactively. But you must be logged in as root or as a superuser (through the
su command). See the lpc man page for details.
</P>
<H3><A NAME="ch12_ 9">
Simple Formatting
</A></H3>
<P>Of course, printing directory listings or short text files is fine, but default printouts of
longer files require formatting with borders, headers, and footers. To get a nicer document with
text files, use the pr command.
</P>
<P><CENTER>
<a href="0229-0232.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0236-0239.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?