📄 ch43_02.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 43] 43.2 Introduction to Printing on UNIX </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-10-23T15:51:42Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch43_01.htm"TITLE="43. Printing"><LINKREL="prev"HREF="ch43_01.htm"TITLE="43.1 Introduction to Printing "><LINKREL="next"HREF="ch43_03.htm"TITLE="43.3 Printer Control with lpc "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch43_01.htm"TITLE="43.1 Introduction to Printing "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 43.1 Introduction to Printing "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 43<BR>Printing</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch43_03.htm"TITLE="43.3 Printer Control with lpc "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 43.3 Printer Control with lpc "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-2390">43.2 Introduction to Printing on UNIX </A></H2><PCLASS="para">Personal computers often have dedicated printers.A dedicated printer is connected to your machine and only you can use it.You can send it only one print job at a time and haveto wait until the printing finishes before you can go back to work.</P><PCLASS="para">UNIX uses a print spooler to allow many users to share a single printer.A user canmake a printing request at any time, even if the printer is currently busy.Requests are queued and processed in order as the printer becomes available.</P><PCLASS="para">UNIX permits multiple printers to be connected to the same system.If there is more than one printer, one printer is set up as the defaultprinter and print jobs are automatically sent there.</P><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-2390-SECT-1.1">43.2.1 System V Printing Commands </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47435"></A><ACLASS="indexterm"NAME="AUTOID-47439"></A><ACLASS="indexterm"NAME="AUTOID-47441"></A><ACLASS="indexterm"NAME="AUTOID-47443"></A><ACLASS="indexterm"NAME="AUTOID-47446"></A>In System V, the <EMCLASS="emphasis">lp</EM> command is used to queue a print job.(Berkeley systems' printer commands are explained below.)When you use <EMCLASS="emphasis">lp</EM>, it spools the file for printing and returns the requestid of your print job.The request id can later be used to cancel the print job, if youdecide to do so.</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lp notes</B></CODE>request-id is lp-2354 (1 file)</PRE></BLOCKQUOTE></P><PCLASS="para">The <EMCLASS="emphasis">lpstat</EM> command can be used to check on the status of your print jobs.The <EMCLASS="emphasis">lpstat</EM> command will tell whether your job is in the queue.</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lpstat</B></CODE>lp-2354 14519 fred on lp</PRE></BLOCKQUOTE></P><PCLASS="para">The message <CODECLASS="literal">on lp</CODE> indicates that the job is currently printing.If your job does notappear at all on the listing, it means your job has finished printing.If the job is listed, but the <CODECLASS="literal">on lp</CODE> message does not appear, then thejob is still in the queue.You can see the status of all jobs in the queue with the <EMCLASS="emphasis">-u</EM> option.You can cancel a job with the <EMCLASS="emphasis">cancel</EM> command.</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lpstat -u</B></CODE>lp-2354 14519 fred on lplp-2355 21321 alicelp-2356 9065 john$ <CODECLASS="userinput"><B>cancel lp-2356</B></CODE>lp-2356: cancelled</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47470"></A>The <EMCLASS="emphasis">lpstat</EM> command can be used to determine what printers areconnected to your system and their names.If there is more than one printer, you can then use the <EMCLASS="emphasis">-d</EM>option with <EMCLASS="emphasis">lp</EM> to specify a printer destinationother than the default.For instance,if a laser printer is configured as <EMCLASS="emphasis">laserp</EM>, then you can enter:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lp -dlaserp myfile</B></CODE></PRE></BLOCKQUOTE></P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-2390-SECT-1.2">43.2.2 Berkeley Printing Commands </A></H3><PCLASS="para">BSD UNIX uses the <EMCLASS="emphasis">lpr</EM> command to queue a print job.<ACLASS="indexterm"NAME="AUTOID-47483"></A><ACLASS="indexterm"NAME="AUTOID-47485"></A><ACLASS="indexterm"NAME="AUTOID-47487"></A><ACLASS="indexterm"NAME="AUTOID-47490"></A><ACLASS="indexterm"NAME="AUTOID-47492"></A>When you use <EMCLASS="emphasis">lpr</EM>, it spools the file for printing.</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lpr notes</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Unlike System V <EMCLASS="emphasis">lp</EM>, the <EMCLASS="emphasis">lpr</EM> command doesn't print a request id.If you need to kill the job, use <EMCLASS="emphasis">lpq</EM> first.The <EMCLASS="emphasis">lpq</EM> command tells you the status of your print jobs.</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lpq</B></CODE>lp is ready and printingRank Owner Job Files Total Sizeactive fred 876 notes 7122 bytes1st alice 877 standard input 28372 bytes2nd john 878 afile bfile ... 985733 bytes</PRE></BLOCKQUOTE></P><PCLASS="para">The word <CODECLASS="literal">active</CODE> in the <CODECLASS="literal">Rank</CODE> column shows the job that'scurrently printing.If your job does notappear at all on the listing, it means your job has finished printing.If a job is not <EMCLASS="emphasis">active</EM>, it's still in the queue.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47512"></A>You can remove a job with the <EMCLASS="emphasis">lprm</EM> command.(First, run <EMCLASS="emphasis">lpq</EM> to get the job number.)</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lprm 877</B></CODE>dfA877<CODECLASS="replaceable"><I>host</I></CODE> dequeuedcfA877<CODECLASS="replaceable"><I>host</I></CODE> dequeued</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-47522"></A>The command<SPANCLASS="link"><EMCLASS="emphasis">lpc status</EM> (<ACLASS="linkend"HREF="ch43_03.htm"TITLE="Printer Control with lpc ">43.3</A>)</SPAN>can be used to determine which printers areconnected to your system and their names.If there is more than one printer, you can then use the <EMCLASS="emphasis">-P</EM>option with <EMCLASS="emphasis">lpr</EM> to specify a printer destination other than the default.For instance,if a laser printer is configured as <EMCLASS="emphasis">laserp</EM>, then you can enter:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>lpr -Plaserp myfile</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">The <EMCLASS="emphasis">-P</EM> option also works with <EMCLASS="emphasis">lpq</EM> and <EMCLASS="emphasis">lprm</EM>.If you'll be using a certain printer often, put its name in the<SPANCLASS="link"><EMCLASS="emphasis">PRINTER</EM> environment variable (<ACLASS="linkend"HREF="ch43_04.htm"TITLE="Using Different Printers ">43.4</A>)</SPAN>.</P></DIV><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">DD</SPAN>, <SPANCLASS="authorinitials">TOR</SPAN>, <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch43_01.htm"TITLE="43.1 Introduction to Printing "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 43.1 Introduction to Printing "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch43_03.htm"TITLE="43.3 Printer Control with lpc "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 43.3 Printer Control with lpc "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">43.1 Introduction to Printing </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">43.3 Printer Control with lpc </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -