⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printing-advanced.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
#  These are PostScript units (72 to the inch).  Modify for A4 or#  whatever size paper you are using:#page_width=612page_height=792border=72##  Check arguments#if [ $# -ne 3 ]; then    echo "Usage: `basename $0` &lt;user&gt; &lt;host&gt; &lt;job&gt;" 1&gt;&amp;2    exit 1fi##  Save these, mostly for readability in the PostScript, below.#user=$1host=$2job=$3date=`date`##  Send the PostScript code to stdout.#exec cat &lt;&lt;EOF%!PS%%  Make sure we do not interfere with user's job that will follow%save%%  Make a thick, unpleasant border around the edge of the paper.%$border $border moveto$page_width $border 2 mul sub 0 rlineto0 $page_height $border 2 mul sub rlinetocurrentscreen 3 -1 roll pop 100 3 1 roll setscreen$border 2 mul $page_width sub 0 rlineto closepath0.8 setgray 10 setlinewidth stroke 0 setgray%%  Display user's login name, nice and large and prominent%/Helvetica-Bold findfont 64 scalefont setfont$page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto($user) show%%  Now show the boring particulars%/Helvetica findfont 14 scalefont setfont/y 200 def[ (Job:) (Host:) (Date:) ] {200 y moveto show /y y 18 sub def }forall/Helvetica-Bold findfont 14 scalefont setfont/y 200 def[ ($job) ($host) ($date) ] {        270 y moveto show /y y 18 sub def} forall%% That is it%restoreshowpageEOF</pre><p>Now, each of the conversion filters and the text filter can call this script to firstgenerate the header page, and then print the user's job. Here is the DVI conversionfilter from earlier in this document, modified to make a header page:</p><pre class="PROGRAMLISTING">#!/bin/sh##  psdf - DVI to PostScript printer filter#  Installed in /usr/local/libexec/psdf##  Invoked by lpd when user runs lpr -d#                orig_args="$@"fail() {    echo "$@" 1&gt;&amp;2    exit 2}while getopts "x:y:n:h:" option; do    case $option in        x|y)  ;; # Ignore        n)    login=$OPTARG ;;        h)    host=$OPTARG ;;        *)    echo "LPD started `basename $0` wrong." 1&gt;&amp;2              exit 2              ;;    esacdone[ "$login" ] || fail "No login name"[ "$host" ] || fail "No host name"( /usr/local/libexec/make-ps-header $login $host "DVI File"  /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args</pre><p>Notice how the filter has to parse the argument list in order to determine the userand host name. The parsing for the other conversion filters is identical. The text filtertakes a slightly different set of arguments, though (see section <ahref="printing-advanced.html#PRINTING-ADVANCED-FILTERS">How Filters Work</a>).</p><p>As we have mentioned before, the above scheme, though fairly simple, disables the``suppress header page'' option (the <var class="OPTION">-h</var> option) to <ttclass="COMMAND">lpr</tt>. If users wanted to save a tree (or a few pennies, if you chargefor header pages), they would not be able to do so, since every filter's going to print aheader page with every job.</p><p>To allow users to shut off header pages on a per-job basis, you will need to use thetrick introduced in section <ahref="printing-advanced.html#PRINTING-ADVANCED-HEADER-PAGES-ACCOUNTING">Accounting forHeader Pages</a>: write an output filter that parses the LPD-generated header page andproduces a <span class="TRADEMARK">PostScript</span> version. If the user submits the jobwith <tt class="COMMAND">lpr -h</tt>, then <b class="APPLICATION">LPD</b> will notgenerate a header page, and neither will your output filter. Otherwise, your outputfilter will read the text from <b class="APPLICATION">LPD</b> and send the appropriateheader page <span class="TRADEMARK">PostScript</span> code to the printer.</p><p>If you have a <span class="TRADEMARK">PostScript</span> printer on a serial line, youcan make use of <tt class="COMMAND">lprps</tt>, which comes with an output filter, <ttclass="COMMAND">psof</tt>, which does the above. Note that <tt class="COMMAND">psof</tt>does not charge for header pages.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="PRINTING-ADVANCED-NETWORK-PRINTERS"name="PRINTING-ADVANCED-NETWORK-PRINTERS">9.4.3 Networked Printing</a></h2><p>FreeBSD supports networked printing: sending jobs to remote printers. Networkedprinting generally refers to two different things:</p><ul><li><p>Accessing a printer attached to a remote host. You install a printer that has aconventional serial or parallel interface on one host. Then, you set up <bclass="APPLICATION">LPD</b> to enable access to the printer from other hosts on thenetwork. Section <a href="printing-advanced.html#PRINTING-ADVANCED-NETWORK-RM">PrintersInstalled on Remote Hosts</a> tells how to do this.</p></li><li><p>Accessing a printer attached directly to a network. The printer has a networkinterface in addition (or in place of) a more conventional serial or parallel interface.Such a printer might work as follows:</p><ul><li><p>It might understand the <b class="APPLICATION">LPD</b> protocol and can even queuejobs from remote hosts. In this case, it acts just like a regular host running <bclass="APPLICATION">LPD</b>. Follow the same procedure in section <ahref="printing-advanced.html#PRINTING-ADVANCED-NETWORK-RM">Printers Installed on RemoteHosts</a> to set up such a printer.</p></li><li><p>It might support a data stream network connection. In this case, you ``attach'' theprinter to one host on the network by making that host responsible for spooling jobs andsending them to the printer. Section <ahref="printing-advanced.html#PRINTING-ADVANCED-NETWORK-NET-IF">Printers with NetworkedData Stream Interfaces</a> gives some suggestions on installing such printers.</p></li></ul></li></ul><div class="SECT3"><h3 class="SECT3"><a id="PRINTING-ADVANCED-NETWORK-RM"name="PRINTING-ADVANCED-NETWORK-RM">9.4.3.1 Printers Installed on Remote Hosts</a></h3><p>The <b class="APPLICATION">LPD</b> spooling system has built-in support for sendingjobs to other hosts also running <b class="APPLICATION">LPD</b> (or are compatible with<b class="APPLICATION">LPD</b>). This feature enables you to install a printer on onehost and make it accessible from other hosts. It also works with printers that havenetwork interfaces that understand the <b class="APPLICATION">LPD</b> protocol.</p><p>To enable this kind of remote printing, first install a printer on one host, the <spanclass="emphasis"><i class="EMPHASIS">printer host</i></span>, using the simple printersetup described in the <a href="printing-intro-setup.html#PRINTING-SIMPLE">Simple PrinterSetup</a> section. Do any advanced setup in <a href="printing-advanced.html">AdvancedPrinter Setup</a> that you need. Make sure to test the printer and see if it works withthe features of <b class="APPLICATION">LPD</b> you have enabled. Also ensure that the<span class="emphasis"><i class="EMPHASIS">local host</i></span> has authorization to usethe <b class="APPLICATION">LPD</b> service in the <span class="emphasis"><iclass="EMPHASIS">remote host</i></span> (see <ahref="printing-advanced.html#PRINTING-ADVANCED-RESTRICTING-REMOTE">Restricting Jobs fromRemote Printers</a>).</p><p>If you are using a printer with a network interface that is compatible with <bclass="APPLICATION">LPD</b>, then the <span class="emphasis"><i class="EMPHASIS">printerhost</i></span> in the discussion below is the printer itself, and the <spanclass="emphasis"><i class="EMPHASIS">printer name</i></span> is the name you configuredfor the printer. See the documentation that accompanied your printer and/orprinter-network interface.</p><div class="TIP"><blockquote class="TIP"><p><b>Tip:</b> If you are using a Hewlett Packard Laserjet then the printer name <varclass="LITERAL">text</var> will automatically perform the LF to CRLF conversion for you,so you will not require the <tt class="FILENAME">hpif</tt> script.</p></blockquote></div><p>Then, on the other hosts you want to have access to the printer, make an entry intheir <tt class="FILENAME">/etc/printcap</tt> files with the following:</p><ol type="1"><li><p>Name the entry anything you want. For simplicity, though, you probably want to use thesame name and aliases as on the printer host.</p></li><li><p>Leave the <var class="LITERAL">lp</var> capability blank, explicitly (<varclass="LITERAL">:lp=:</var>).</p></li><li><p>Make a spooling directory and specify its location in the <varclass="LITERAL">sd</var> capability. <b class="APPLICATION">LPD</b> will store jobs herebefore they get sent to the printer host.</p></li><li><p>Place the name of the printer host in the <var class="LITERAL">rm</var>capability.</p></li><li><p>Place the printer name on the <span class="emphasis"><i class="EMPHASIS">printerhost</i></span> in the <var class="LITERAL">rp</var> capability.</p></li></ol><p>That is it. You do not need to list conversion filters, page dimensions, or anythingelse in the <tt class="FILENAME">/etc/printcap</tt> file.</p><p>Here is an example. The host <tt class="HOSTID">rose</tt> has two printers, <varclass="LITERAL">bamboo</var> and <var class="LITERAL">rattan</var>. We will enable userson the host <tt class="HOSTID">orchid</tt> to print to those printers. Here is the <ttclass="FILENAME">/etc/printcap</tt> file for <tt class="HOSTID">orchid</tt> (back fromsection <a href="printing-advanced.html#PRINTING-ADVANCED-HEADER-PAGES-ENABLING">EnablingHeader Pages</a>). It already had the entry for the printer <varclass="LITERAL">teak</var>; we have added entries for the two printers on the host <ttclass="HOSTID">rose</tt>:</p><pre class="PROGRAMLISTING">##  /etc/printcap for host orchid - added (remote) printers on rose###  teak is local; it is connected directly to orchid:#teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\        :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\        :if=/usr/local/libexec/ifhp:\        :vf=/usr/local/libexec/vfhp:\        :of=/usr/local/libexec/ofhp:##  rattan is connected to rose; send jobs for rattan to rose:#rattan|line|diablo|lp|Diablo 630 Line Printer:\        :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan:##  bamboo is connected to rose as well:#bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\        :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:</pre><p>Then, we just need to make spooling directories on <tt class="HOSTID">orchid</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">chmod 770 /var/spool/lpd/rattan /var/spool/lpd/bamboo</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">chown daemon:daemon /var/spool/lpd/rattan /var/spool/lpd/bamboo</kbd></pre><p>Now, users on <tt class="HOSTID">orchid</tt> can print to <varclass="LITERAL">rattan</var> and <var class="LITERAL">bamboo</var>. If, for example, auser on <tt class="HOSTID">orchid</tt> typed</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbdclass="USERINPUT">lpr -P bamboo -d sushi-review.dvi</kbd></pre>the <b class="APPLICATION">LPD</b> system on <tt class="HOSTID">orchid</tt> would copythe job to the spooling directory <tt class="FILENAME">/var/spool/lpd/bamboo</tt> andnote that it was a DVI job. As soon as the host <tt class="HOSTID">rose</tt> has room inits <var class="LITERAL">bamboo</var> spooling directory, the two <bclass="APPLICATION">LPDs</b> would transfer the file to <tt class="HOSTID">rose</tt>. Thefile would wait in <tt class="HOSTID">rose</tt>'s queue until it was finally printed. Itwould be converted from DVI to <span class="TRADEMARK">PostScript</span> (si

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -