• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/LPRng/DOCS/LPRng-Reference-Multipart/
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3<html>
4  <head>
5    <meta name="generator" content="HTML Tidy, see www.w3.org">
6    <title>Printing from lpr Directly To A Device</title>
7    <meta name="GENERATOR" content=
8    "Modular DocBook HTML Stylesheet Version 1.7">
9    <link rel="HOME" title=" LPRng Reference Manual" href=
10    "index.htm">
11    <link rel="UP" title="Print Spooling Tutorial " href=
12    "tutorial.htm">
13    <link rel="PREVIOUS" title="Banner Printing and the OF filter"
14    href="x3273.htm">
15    <link rel="NEXT" title=
16    "Moving Jobs From Queue to Queue and Redirecting Queues" href=
17    "x3423.htm">
18  </head>
19
20  <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link=
21  "#0000FF" vlink="#840084" alink="#0000FF">
22    <div class="NAVHEADER">
23      <table summary="Header navigation table" width="100%" border=
24      "0" cellpadding="0" cellspacing="0">
25        <tr>
26          <th colspan="3" align="center">LPRng Reference Manual: 5
27          Sep 2003 (For LPRng-3.8.22)</th>
28        </tr>
29
30        <tr>
31          <td width="10%" align="left" valign="bottom"><a href=
32          "x3273.htm" accesskey="P">Prev</a></td>
33
34          <td width="80%" align="center" valign="bottom">Chapter 4.
35          Print Spooling Tutorial</td>
36
37          <td width="10%" align="right" valign="bottom"><a href=
38          "x3423.htm" accesskey="N">Next</a></td>
39        </tr>
40      </table>
41      <hr align="LEFT" width="100%">
42    </div>
43
44    <div class="SECT1">
45      <h1 class="SECT1"><a name="AEN3376">4.13. Printing from <b
46      class="APPLICATION">lpr</b> Directly To A Device</a></h1>
47
48      <p>While the most reliable way to print is to send jobs to a
49      print spooler, sometimes it is desirable to print directly to
50      a printer. This method is supported by the special <var
51      class="LITERAL">:direct</var> printcap flag or the <b class=
52      "APPLICATION">lpr</b> <var class="LITERAL">-Y</var> command
53      line flag. The following shows the effects of this flag:</p>
54
55      <div class="INFORMALEXAMPLE">
56        <a name="AEN3383"></a>
57<pre class="SCREEN">
58    lpr -Y -Phost%port file1 file2 ...
59    Eqivalent to:
60      ( for i in file1 file2 ... ; do
61        $filter $i
62      done ) | tcpip_connection( host%port)
63    
64    lpr -Y -P/dev/lp file1 file2 ...
65    Eqivalent to:
66      ( for i in file1 file2 ... ; do
67        $filter $i
68      done ) &gt;&gt;/dev/lp
69    
70    lpr -Y -P '|/program' file1 file2 ...
71    Eqivalent to:
72      ( for i in file1 file2 ... ; do
73        $filter $i
74      done ) | /program
75</pre>
76      </div>
77
78      <p>The above examples show how we can use the command line
79      options to send files directly to a printer. You can also
80      create a printcap that will do the same:</p>
81
82      <div class="INFORMALEXAMPLE">
83        <a name="AEN3386"></a>
84<pre class="SCREEN">
85    lp:direct:lp=/tmp/a:remote_support=R
86    Command:
87      lpr -Plp file1 file2 ...
88    Equivalent to:
89    lpr -P/tmp/a -Y file1 file2 ...
90    
91    Example:
92    <samp class="PROMPT">h4: {228} %</samp> <kbd class=
93"USERINPUT">lp -P/tmp/a /tmp/hi</kbd>
94    <samp class="PROMPT">h4: {229} %</samp> <kbd class=
95"USERINPUT">cat /tmp/a /tmp/hi</kbd>
96    hi
97    <samp class="PROMPT">h4: {230} %</samp> <kbd class=
98"USERINPUT">lp -Plp /tmp/hi</kbd>
99    <samp class="PROMPT">h4: {231} %</samp> <kbd class=
100"USERINPUT">cat /tmp/a /tmp/hi</kbd>
101    hi
102    hi
103</pre>
104      </div>
105
106      <p>The <b class="APPLICATION">lpr</b> <var class="LITERAL">-X
107      filter</var> option allows us to specify a user filter on the
108      command line. We will use a simple example to show how this
109      capability could be used in practice. Create the <tt class=
110      "FILENAME">/tmp/pass</tt> file with the following contents,
111      and give it executable permissions as shown below:</p>
112
113      <div class="INFORMALEXAMPLE">
114        <a name="AEN3400"></a>
115<pre class="SCREEN">
116    #!/bin/sh
117    # /tmp/pass file
118    echo LEADER
119    cat
120    echo TRAILER
121    exit 0
122</pre>
123      </div>
124      <br>
125      <br>
126
127      <p>Execute the following commands to print the <tt class=
128      "FILENAME">/tmp/hi</tt> file and observe the results:</p>
129
130      <div class="INFORMALEXAMPLE">
131        <a name="AEN3404"></a>
132<pre class="SCREEN">
133    <samp class="PROMPT">h4: {232} %</samp> <kbd class=
134"USERINPUT">cp /dev/null /tmp/a</kbd>
135    <samp class="PROMPT">h4: {233} %</samp> <kbd class=
136"USERINPUT">lpr -P/tmp/a -X /tmp/pass /tmp/hi</kbd>
137    <samp class="PROMPT">h4: {234} %</samp> <kbd class=
138"USERINPUT">cat /tmp/a</kbd>
139    LEADER
140    hi
141    TRAILER
142</pre>
143      </div>
144      <br>
145      <br>
146
147      <p>As we see from the example, our filter has processed the
148      input file and added the <var class="LITERAL">LEADER</var>
149      and <var class="LITERAL">TRAILER</var> strings. In practice,
150      the actual processing of the input job would be far more
151      elaborate, and may do such things as incorporate files or
152      other material available only on the local system. We can
153      also use a printcap entry:</p>
154
155      <div class="INFORMALEXAMPLE">
156        <a name="AEN3415"></a>
157<pre class="SCREEN">
158    lp:direct:lp=/tmp/a:filter=/tmp/pass
159    
160    <samp class="PROMPT">h4: {235} %</samp> <kbd class=
161"USERINPUT">cp /dev/null /tmp/a</kbd>
162    <samp class="PROMPT">h4: {236} %</samp> <kbd class=
163"USERINPUT">lpr -Plp /tmp/hi</kbd>
164    <samp class="PROMPT">h4: {237} %</samp> <kbd class=
165"USERINPUT">cat /tmp/a</kbd>
166    LEADER
167    hi
168    TRAILER
169</pre>
170      </div>
171    </div>
172
173    <div class="NAVFOOTER">
174      <hr align="LEFT" width="100%">
175
176      <table summary="Footer navigation table" width="100%" border=
177      "0" cellpadding="0" cellspacing="0">
178        <tr>
179          <td width="33%" align="left" valign="top"><a href=
180          "x3273.htm" accesskey="P">Prev</a></td>
181
182          <td width="34%" align="center" valign="top"><a href=
183          "index.htm" accesskey="H">Home</a></td>
184
185          <td width="33%" align="right" valign="top"><a href=
186          "x3423.htm" accesskey="N">Next</a></td>
187        </tr>
188
189        <tr>
190          <td width="33%" align="left" valign="top">Banner Printing
191          and the OF filter</td>
192
193          <td width="34%" align="center" valign="top"><a href=
194          "tutorial.htm" accesskey="U">Up</a></td>
195
196          <td width="33%" align="right" valign="top">Moving Jobs
197          From Queue to Queue and Redirecting Queues</td>
198        </tr>
199      </table>
200    </div>
201  </body>
202</html>
203
204