1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3  <head>
4    <meta name="generator" content="HTML Tidy, see www.w3.org">
5    <title>The Printing Cookbook</title>
6    <meta name="GENERATOR" content=
7    "Modular DocBook HTML Stylesheet Version 1.71 ">
8  </head>
9
10  <body class="BOOK" bgcolor="#FFFFFF" text="#000000" link=
11  "#0000FF" vlink="#840084" alink="#0000FF">
12    <div class="BOOK">
13      <a name="AEN1"></a>
14<table><tr valign=top>
15<td width=25%>
16<a href="http://www.lprng.com">
17<img align=left SRC="LPRng.jpg" ALT="LPRngLogo" height=60>
18</a>
19</td>
20<td width=50%></td><td width=25% >
21<a href="http://www.lprng.com">
22<img align=right SRC="LPRngT-L.jpg" ALT="LPRngTool" height=75>
23</a>
24</td></tr></table>
25
26      <div class="TITLEPAGE">
27        <h1 class="TITLE"><a name="AEN2">The Printing
28        Cookbook</a></h1>
29
30        <h3 class="AUTHOR"><a name="AEN4">Patrick A Powell</a></h3>
31
32        <div class="AFFILIATION">
33          <div class="ADDRESS">
34            <p class="ADDRESS">papowell@lprng.com<br>
35            AStArt&nbsp;Technologies<br>
36            9475&nbsp;Chesapeake&nbsp;Dr,&nbsp;Suite&nbsp;D,<br>
37            San&nbsp;Diego,&nbsp;CA&nbsp;92123<br>
38            Phone&nbsp;858-874-6543<br>
39            Fax&nbsp;858-279-8424</p>
40          </div>
41        </div>
42
43        <p class="COPYRIGHT">Copyright &copy; 2001 by Patrick
44        Powell</p>
45
46        <div>
47          <div class="ABSTRACT">
48            <a name="AEN17"></a>
49
50            <p>This is a set of <i class="EMPHASIS">Recipes for
51            Printing</i>, a set of procedures that can be used to
52            set up and diagnose printing in a range of system
53            environments. The main emphasis will be on using the <b
54            class="APPLICATION">LPRng</b> print spooler, either by
55            itself or with other print spooling systems.</p>
56          </div>
57        </div>
58        <hr>
59      </div>
60
61      <div class="TOC">
62        <dl>
63          <dt><b>Table of Contents</b></dt>
64
65          <dt><a href="#AEN21">Preface</a></dt>
66
67          <dd>
68            <dl>
69              <dt>1. <a href="#AEN34">Acknowledgements</a></dt>
70
71              <dt>2. <a href="#AEN40">Conventions</a></dt>
72
73              <dt>3. <a href="#AEN67">Disclaimer</a></dt>
74            </dl>
75          </dd>
76
77          <dt>1. <a href="#AEN70">Introduction - The Basics and
78          Variations</a></dt>
79
80          <dd>
81            <dl>
82              <dt>1.1. <a href="#AEN160">Checking the Printing
83              System</a></dt>
84
85              <dt>1.2. <a href="#AEN168">Fixing the
86              Problems</a></dt>
87            </dl>
88          </dd>
89
90          <dt>2. <a href="#AEN181">Simple Spooling</a></dt>
91
92          <dd>
93            <dl>
94              <dt>2.1. <a href="#AEN187">Setting Up The Print
95              Queues</a></dt>
96
97              <dt>2.2. <a href="#AEN226">Diagnostics for Spooling
98              Problems</a></dt>
99
100              <dt>2.3. <a href="#AEN280">What Went Wrong With My
101              Job?</a></dt>
102
103              <dt>2.4. <a href="#AEN331">Diagnostics for <b class=
104              "APPLICATION">lpd</b> Problems</a></dt>
105            </dl>
106          </dd>
107
108          <dt>3. <a href="#AEN371">Printers</a></dt>
109
110          <dd>
111            <dl>
112              <dt>3.1. <a href="#AEN381">Interface</a></dt>
113
114              <dt>3.2. <a href="#AEN388">Parallel Port</a></dt>
115
116              <dt>3.3. <a href="#AEN439">Network Ports</a></dt>
117
118              <dt>3.4. <a href="#AEN647">Sending To SMB (Samba,
119              Microsoft) Printer, Novell, Appletalk</a></dt>
120
121              <dt>3.5. <a href="#AEN703">Serial Port</a></dt>
122            </dl>
123          </dd>
124
125          <dt>4. <a href="#AEN728">Printer Job Formats</a></dt>
126
127          <dd>
128            <dl>
129              <dt>4.1. <a href="#AEN745">PostScript</a></dt>
130
131              <dt>4.2. <a href="#AEN788">PCL</a></dt>
132
133              <dt>4.3. <a href="#AEN803">Printer Job Language (PJL)
134              and PostScript, PCL</a></dt>
135
136              <dt>4.4. <a href="#AEN811">Text Files</a></dt>
137
138              <dt>4.5. <a href="#AEN826">Magical Mystery
139              Proprietary Format</a></dt>
140
141              <dt>4.6. <a href="#AEN859">Printing Test
142              Pages</a></dt>
143            </dl>
144          </dd>
145
146          <dt>5. <a href="#AEN872">Filters</a></dt>
147
148          <dd>
149            <dl>
150              <dt>5.1. <a href="#AEN951">Writing Your Own
151              Filter</a></dt>
152
153              <dt>5.2. <a href="#AEN991">The <b class=
154              "APPLICATION">LPRng</b> IFHP Filter</a></dt>
155
156              <dt>5.3. <a href="#AEN1059">Taming the Wild Phaser
157              Printer</a></dt>
158            </dl>
159          </dd>
160
161          <dt>6. <a href="#AEN1071">Banner Pages and
162          Accounting</a></dt>
163
164          <dd>
165            <dl>
166              <dt>6.1. <a href="#AEN1074">Suppressing Banner
167              Pages</a></dt>
168
169              <dt>6.2. <a href="#AEN1100">Forcing Banner
170              Pages</a></dt>
171
172              <dt>6.3. <a href="#AEN1108">Generating Banner
173              Pages</a></dt>
174
175              <dt>6.4. <a href="#AEN1130">Accounting</a></dt>
176
177              <dt>6.5. <a href="#AEN1162">Accounting
178              Gotchas</a></dt>
179
180              <dt>6.6. <a href="#AEN1170">Accounting Including
181              Banner Pages</a></dt>
182            </dl>
183          </dd>
184
185          <dt>7. <a href="#AEN1177">Printer Pools and Load
186          Sharing</a></dt>
187
188          <dd>
189            <dl>
190              <dt>7.1. <a href="#AEN1205">Implementing Smart Load
191              Balancing</a></dt>
192
193              <dt>7.2. <a href="#AEN1234">Using <tt class=
194              "LITERAL">:chooser</tt> Exit Codes</a></dt>
195            </dl>
196          </dd>
197
198          <dt>8. <a href="#AEN1244">Wildcards, Bounce Queues, and
199          Forwarding</a></dt>
200
201          <dd>
202            <dl>
203              <dt>8.1. <a href="#AEN1251">Bounce Queues</a></dt>
204
205              <dt>8.2. <a href="#AEN1260">Adding -Z Options Using
206              Bounce Queues</a></dt>
207
208              <dt>8.3. <a href="#INCOMING">Adding Options By
209              Modifying Control File</a></dt>
210            </dl>
211          </dd>
212
213          <dt>9. <a href="#AEN1295">Form Support and Hold
214          Queues</a></dt>
215
216          <dd>
217            <dl>
218              <dt>9.1. <a href="#AEN1298">Hold Queues</a></dt>
219            </dl>
220          </dd>
221
222          <dt>10. <a href="#AEN1351">Interfacing to Vintage,
223          Legacy, and SunOS Print Spoolers</a></dt>
224
225          <dt>11. <a href="#AEN1363">Managing Enterprise Level
226          Printing Systems</a></dt>
227
228          <dd>
229            <dl>
230              <dt>11.1. <a href="#AEN1366">Templates and Standard
231              Configurations</a></dt>
232
233              <dt>11.2. <a href="#AEN1383">Master Print Servers,
234              One User Printcap</a></dt>
235
236              <dt>11.3. <a href="#AEN1391">Master Print Servers,
237              Local Spooling</a></dt>
238
239              <dt>11.4. <a href="#AEN1399">Master Print Servers,
240              Selection by User</a></dt>
241
242              <dt>11.5. <a href="#AEN1411">The Great Grand Dad Of
243              All Printcap Files</a></dt>
244
245              <dt>11.6. <a href="#AEN1417">Using Printcap Filters
246              and Central Databases</a></dt>
247            </dl>
248          </dd>
249
250          <dt>12. <a href="#AEN1434"><b class=
251          "APPLICATION">LPRngTool</b></a></dt>
252
253          <dt>A. <a href="#SECFEATURES"><b class=
254          "APPLICATION">LPRng</b></a></dt>
255
256          <dd>
257            <dl>
258              <dt>A.1. <a href="#MAILLIST">Documentation</a></dt>
259
260              <dt>A.2. <a href="#AEN1548">Installation</a></dt>
261
262              <dt>A.3. <a href="#AEN1560">License</a></dt>
263
264              <dt>A.4. <a href="#AEN1566">Commercial
265              Support</a></dt>
266
267              <dt>A.5. <a href="#LPRNGDIST">Web Site, FTP Site, and
268              Mirrors</a></dt>
269
270              <dt>A.6. <a href="#AEN1607">Mailing List</a></dt>
271
272              <dt>A.7. <a href="#FAQREF">PGP Public Key</a></dt>
273            </dl>
274          </dd>
275
276          <dt>B. <a href="#AEN1621">References and
277          Standards</a></dt>
278
279          <dd>
280            <dl>
281              <dt>B.1. <a href="#AEN1625">RFCs</a></dt>
282
283              <dt>B.2. <a href="#POSTSCRIPT">PostScript</a></dt>
284
285              <dt>B.3. <a href="#PCL">HP PCL 5</a></dt>
286
287              <dt>B.4. <a href="#PJL">HP PJL</a></dt>
288
289              <dt>B.5. <a href="#AEN1668">PDF</a></dt>
290            </dl>
291          </dd>
292
293          <dt>C. <a href="#RFC1179REF">RFC 1179 - Line Printer
294          Daemon Protocol</a></dt>
295
296          <dd>
297            <dl>
298              <dt>C.1. <a href="#LPDPORT">Ports and
299              Connections</a></dt>
300
301              <dt>C.2. <a href="#REMOTESUPPORT">Protocol Requests
302              and Replies</a></dt>
303
304              <dt>C.3. <a href="#JOBTRANSFER">Job Transfer</a></dt>
305
306              <dt>C.4. <a href="#AEN2015">Data File
307              Transfer</a></dt>
308
309              <dt>C.5. <a href="#AEN2051">Control File
310              Contents</a></dt>
311
312              <dt>C.6. <a href="#AEN2250"><b class=
313              "APPLICATION">lpq</b> Requests</a></dt>
314
315              <dt>C.7. <a href="#AEN2270"><b class=
316              "APPLICATION">lprm</b> Requests</a></dt>
317
318              <dt>C.8. <a href="#LPCREREAD">LPC Requests</a></dt>
319
320              <dt>C.9. <a href="#SENDBLOCKFORMAT">Block Job
321              Transfer</a></dt>
322
323              <dt>C.10. <a href="#AEN2472">Authenticated
324              Transfer</a></dt>
325            </dl>
326          </dd>
327        </dl>
328      </div>
329
330      <div class="LOT">
331        <dl class="LOT">
332          <dt><b>List of Tables</b></dt>
333
334          <dt>3-1. <a href="#NEWPS">Network Print Server
335          Configuration Information</a></dt>
336
337          <dt>C-1. <a href="#RF1179COMMANDS">RFC1179
338          Commands</a></dt>
339
340          <dt>C-2. <a href="#CFLINES">Control File Lines and
341          Purpose</a></dt>
342
343          <dt>C-3. <a href="#LPCCOMMANDS">LPC Commands</a></dt>
344        </dl>
345      </div>
346
347      <div class="LOT">
348        <dl class="LOT">
349          <dt><b>List of Figures</b></dt>
350
351          <dt>1. <a href="#AEN60"><b class="APPLICATION">lpq</b>
352          status</a></dt>
353
354          <dt>1-1. <a href="#FG1">Print Spooler
355          Architecture</a></dt>
356
357          <dt>1-2. <a href="#FG2">Configuration Files</a></dt>
358
359          <dt>1-3. <a href="#FG3">Printcap</a></dt>
360
361          <dt>1-4. <a href="#FG4">lpd.conf Defaults File</a></dt>
362
363          <dt>1-5. <a href="#FG5">lpd.perm Permissions
364          File</a></dt>
365
366          <dt>1-6. <a href="#FG6">Clients and Configuration
367          Files</a></dt>
368
369          <dt>1-7. <a href="#FG7">${HOME}/.printcap
370          Information</a></dt>
371
372          <dt>1-8. <a href="#FG8">Using <b class=
373          "APPLICATION">checkpc</b></a></dt>
374
375          <dt>1-9. <a href="#FG9">Using <b class=
376          "APPLICATION">checkpc</b> -f</a></dt>
377
378          <dt>2-1. <a href="#AEN184">Basic Printcap Entry</a></dt>
379
380          <dt>2-2. <a href="#AEN189">Run checkpc</a></dt>
381
382          <dt>2-3. <a href="#AEN194">Check for Running
383          Server</a></dt>
384
385          <dt>2-4. <a href="#AEN200">Run <b class=
386          "APPLICATION">lpq</b></a></dt>
387
388          <dt>2-5. <a href="#AEN205">Run <b class=
389          "APPLICATION">lpc</b></a></dt>
390
391          <dt>2-6. <a href="#AEN212">Run <b class=
392          "APPLICATION">lpr</b></a></dt>
393
394          <dt>2-7. <a href="#AEN217">Run <b class=
395          "APPLICATION">lprm</b></a></dt>
396
397          <dt>2-8. <a href="#AEN222">Enable Printing</a></dt>
398
399          <dt>2-9. <a href="#AEN228">Using <b class=
400          "APPLICATION">lpr</b> -V</a></dt>
401
402          <dt>2-10. <a href="#AEN236">The <b class=
403          "APPLICATION">lpr</b> Options</a></dt>
404
405          <dt>2-11. <a href="#AEN242">Debug Options</a></dt>
406
407          <dt>2-12. <a href="#AEN247">The <b class=
408          "APPLICATION">lpr</b> -D1 Output</a></dt>
409
410          <dt>2-13. <a href="#AEN258">Using <b class=
411          "APPLICATION">lpr</b> -Dnetwork</a></dt>
412
413          <dt>2-14. <a href="#AEN270">Debugging <b class=
414          "APPLICATION">lpq</b></a></dt>
415
416          <dt>2-15. <a href="#AEN282">Basic <b class=
417          "APPLICATION">lpq</b> Information</a></dt>
418
419          <dt>2-16. <a href="#AEN293">Using the <b class=
420          "APPLICATION">lpq</b> -l Option</a></dt>
421
422          <dt>2-17. <a href="#AEN306">Using the <b class=
423          "APPLICATION">lpq</b> -L Option</a></dt>
424
425          <dt>2-18. <a href="#AEN313">Job Completion</a></dt>
426
427          <dt>2-19. <a href="#AEN318">Summary Status
428          Displays</a></dt>
429
430          <dt>2-20. <a href="#AEN334"><b class=
431          "APPLICATION">lpd</b> Options</a></dt>
432
433          <dt>2-21. <a href="#AEN340">Using <b class=
434          "APPLICATION">lpd</b> Debug Options</a></dt>
435
436          <dt>2-22. <a href="#AEN346">Debugging Spool
437          Queue</a></dt>
438
439          <dt>2-23. <a href="#AEN357">Setting Queue Debug
440          Options</a></dt>
441
442          <dt>2-24. <a href="#AEN364"><tt class="LITERAL">log</tt>
443          File</a></dt>
444
445          <dt>3-1. <a href="#AEN373">Printer Types</a></dt>
446
447          <dt>3-2. <a href="#AEN383">Interface Types</a></dt>
448
449          <dt>3-3. <a href="#P2">Parallel Port</a></dt>
450
451          <dt>3-4. <a href="#P1">Parallel Port Printcap</a></dt>
452
453          <dt>3-5. <a href="#P3">Loading Linux Parallel Port
454          Driver</a></dt>
455
456          <dt>3-6. <a href="#P4">Parallel Port Problems</a></dt>
457
458          <dt>3-7. <a href="#N1">Network Ports</a></dt>
459
460          <dt>3-8. <a href="#N2">Network Port Printcap</a></dt>
461
462          <dt>3-9. <a href="#N3">Benefits of Network Port
463          Printcap</a></dt>
464
465          <dt>3-10. <a href="#N4">Network Print Server</a></dt>
466
467          <dt>3-11. <a href="#AEN649">Using Program To Send To
468          Printer</a></dt>
469
470          <dt>3-12. <a href="#AEN656">Protocols, Packages, and
471          Transfer Programs</a></dt>
472
473          <dt>3-13. <a href="#AEN664">Printcap For Transfer
474          Programs</a></dt>
475
476          <dt>3-14. <a href="#WRAPPER">Samba <b class=
477          "APPLICATION">smbclient</b> Wrapper</a></dt>
478
479          <dt>3-15. <a href="#PC"><tt class=
480          "LITERAL">$PRINTCAP_ENTRY</tt></a></dt>
481
482          <dt>3-16. <a href="#AEN697">Novell and Appletalk
483          Wrappers</a></dt>
484
485          <dt>3-17. <a href="#S1">Serial Port</a></dt>
486
487          <dt>3-18. <a href="#S2">Serial Port Printcap</a></dt>
488
489          <dt>4-1. <a href="#AEN730">Page Description
490          Lanaguages</a></dt>
491
492          <dt>4-2. <a href="#AEN735">How To Identify Print
493          Formats</a></dt>
494
495          <dt>4-3. <a href="#FILE">Using the <b class=
496          "APPLICATION">file</b> Application</a></dt>
497
498          <dt>4-4. <a href="#AEN747">One PostScript Page</a></dt>
499
500          <dt>4-5. <a href="#AEN751">Generate One Page</a></dt>
501
502          <dt>4-6. <a href="#AEN757">PostScript Document
503          Structuring Conventions</a></dt>
504
505          <dt>4-7. <a href="#AEN767">Tools for PostScript Document
506          Manipulation</a></dt>
507
508          <dt>4-8. <a href="#AEN774">Selection of Pages + 4up
509          Printing</a></dt>
510
511          <dt>4-9. <a href="#AEN777">PostScript Output</a></dt>
512
513          <dt>4-10. <a href="#AEN782">End Of PostScript Job: ^D
514          (CTRL-D)</a></dt>
515
516          <dt>4-11. <a href="#AEN790">One PCL Page</a></dt>
517
518          <dt>4-12. <a href="#AEN795">Generate One Page</a></dt>
519
520          <dt>4-13. <a href="#AEN805">PJL Example</a></dt>
521
522          <dt>4-14. <a href="#AEN813">Text Files and The
523          Jaggies</a></dt>
524
525          <dt>4-15. <a href="#AEN822">Fixing The Jaggies</a></dt>
526
527          <dt>4-16. <a href="#AEN828">Magical Mystery
528          Formats</a></dt>
529
530          <dt>4-17. <a href="#AEN835">GhostScript To The
531          Rescue</a></dt>
532
533          <dt>4-18. <a href="#AEN839">GhostScript Devices</a></dt>
534
535          <dt>4-19. <a href="#AEN846">GhostScript Support</a></dt>
536
537          <dt>4-20. <a href="#AEN861">Printing Test Pages To
538          Parallel Port</a></dt>
539
540          <dt>4-21. <a href="#AEN865">Using Netcat (<b class=
541          "APPLICATION">nc</b>)</a></dt>
542
543          <dt>5-1. <a href="#AEN874">Filters</a></dt>
544
545          <dt>5-2. <a href="#AEN880">Filter Specification in
546          Printcap Entry</a></dt>
547
548          <dt>5-3. <a href="#AEN887">Specifying Job Datafile
549          Format</a></dt>
550
551          <dt>5-4. <a href="#AEN901">Filter Execution
552          Environment</a></dt>
553
554          <dt>5-5. <a href="#AEN915">Command Line Options</a></dt>
555
556          <dt>5-6. <a href="#AEN929">Filter Exit Codes</a></dt>
557
558          <dt>5-7. <a href="#AEN941">Solid As A Rock Filter
559          Operation</a></dt>
560
561          <dt>5-8. <a href="#AEN946">Solid As A Used Paper Coffee
562          Filter Operation</a></dt>
563
564          <dt>5-9. <a href="#FILTERTEMPLATE">Filter Template in <b
565          class="APPLICATION">perl</b></a></dt>
566
567          <dt>5-10. <a href="#AEN964">How To Determine The Type of
568          Job File</a></dt>
569
570          <dt>5-11. <a href="#FPC">Printcap for Filter</a></dt>
571
572          <dt>5-12. <a href="#FDB">Using Filter With
573          $debug=1</a></dt>
574
575          <dt>5-13. <a href="#FNODB">Using Filter With
576          $debug=0</a></dt>
577
578          <dt>5-14. <a href="#AEN994"><b class=
579          "APPLICATION">ifhp</b></a></dt>
580
581          <dt>5-15. <a href="#AEN1006">ifhp.conf Configuration
582          Information</a></dt>
583
584          <dt>5-16. <a href="#AEN1011">Default Printer Magic
585          Cookies</a></dt>
586
587          <dt>5-17. <a href="#AEN1016">PostScript Only
588          Printer</a></dt>
589
590          <dt>5-18. <a href="#AEN1026">Using the <b class=
591          "APPLICATION">ifhp</b> Filter</a></dt>
592
593          <dt>5-19. <a href="#AEN1033">Example of <b class=
594          "APPLICATION">ifhp</b> Operation</a></dt>
595
596          <dt>5-20. <a href="#AEN1041">Using -Z to Pass Options to
597          <b class="APPLICATION">ifhp</b></a></dt>
598
599          <dt>5-21. <a href="#AEN1050">Testing <b class=
600          "APPLICATION">ifhp</b> Operations</a></dt>
601
602          <dt>5-22. <a href="#AEN1065">Phaser/Appsocket
603          Support</a></dt>
604
605          <dt>6-1. <a href="#NB1">Changing JetDirect
606          Configuration</a></dt>
607
608          <dt>6-2. <a href="#AEN1085">Printcap Option <tt class=
609          "LITERAL">:sh</tt> and <b class="APPLICATION">lpr</b> -h
610          (No Header) Option</a></dt>
611
612          <dt>6-3. <a href="#AEN1096">Removing Banner
613          Lines</a></dt>
614
615          <dt>6-4. <a href="#AEN1105">Forcing Banner Pages</a></dt>
616
617          <dt>6-5. <a href="#AEN1110">Generating Banner
618          Page</a></dt>
619
620          <dt>6-6. <a href="#AEN1134">Basic Accounting
621          Information</a></dt>
622
623          <dt>6-7. <a href="#AEN1141">Accounting File
624          Information</a></dt>
625
626          <dt>6-8. <a href="#AC2">Filter Accounting
627          Information</a></dt>
628
629          <dt>6-9. <a href="#AC3">Accounting Gotchas</a></dt>
630
631          <dt>6-10. <a href="#AEN1172">Accounting Using Banner
632          Pages</a></dt>
633
634          <dt>7-1. <a href="#PP1">Printer Pools and Load
635          Sharing</a></dt>
636
637          <dt>7-2. <a href="#PP2">Load Balancing Printcap</a></dt>
638
639          <dt>7-3. <a href="#AEN1193">Load Balancing to Remote
640          Queues</a></dt>
641
642          <dt>7-4. <a href="#AEN1198">Printcap for Chooser</a></dt>
643
644          <dt>7-5. <a href="#AEN1207">Chooser Program
645          Operation</a></dt>
646
647          <dt>7-6. <a href="#AEN1217">Filter Template in <b class=
648          "APPLICATION">Perl</b></a></dt>
649
650          <dt>7-7. <a href="#AEN1222">Choosing A
651          Destintation</a></dt>
652
653          <dt>7-8. <a href="#AEN1237">Chooser Exit Codes</a></dt>
654
655          <dt>8-1. <a href="#AEN1247">Evil (BAD) Way</a></dt>
656
657          <dt>8-2. <a href="#AEN1253">Not So Evil Way</a></dt>
658
659          <dt>8-3. <a href="#AEN1262">Add Options Using <tt class=
660          "LITERAL">:append_z</tt></a></dt>
661
662          <dt>8-4. <a href="#AEN1270">Diabolically Fiendishly
663          Clever Method</a></dt>
664
665          <dt>8-5. <a href="#UPDATEZ">Using <tt class=
666          "LITERAL">update_z</tt></a></dt>
667
668          <dt>9-1. <a href="#AEN1300">Hold Queues</a></dt>
669
670          <dt>9-2. <a href="#AEN1303">All Hold Queues</a></dt>
671
672          <dt>9-3. <a href="#AEN1308">Releasing Jobs for
673          Printing</a></dt>
674
675          <dt>9-4. <a href="#AEN1315">Releasing Jobs For Scheduled
676          Print Run</a></dt>
677
678          <dt>9-5. <a href="#HOLDCLASS">Using Job Classes</a></dt>
679
680          <dt>9-6. <a href="#AEN1334">Setting New Job Classes and
681          Disabling Job Classes</a></dt>
682
683          <dt>9-7. <a href="#AEN1340">Modifying Control File Using
684          <b class="APPLICATION">update_class</b></a></dt>
685
686          <dt>9-8. <a href="#AEN1346">The <b class=
687          "APPLICATION">update_class</b> Filter</a></dt>
688
689          <dt>10-1. <a href="#AEN1359">Using <tt class=
690          "LITERAL">:bk</tt> (Berkeley Kompatible) Flag</a></dt>
691
692          <dt>11-1. <a href="#AEN1368">Templates in
693          Printcaps</a></dt>
694
695          <dt>11-2. <a href="#AEN1373">Using <b class=
696          "APPLICATION">lpc</b> client all</a></dt>
697
698          <dt>11-3. <a href="#AEN1385">Master User Printcap File,
699          No Local Spooling</a></dt>
700
701          <dt>11-4. <a href="#AEN1393">Master User Printcap File,
702          Local Spooling</a></dt>
703
704          <dt>11-5. <a href="#AEN1401">Master User Printcap File,
705          No Local Spooling</a></dt>
706
707          <dt>11-6. <a href="#AEN1413">All In One</a></dt>
708
709          <dt>11-7. <a href="#AEN1419">Printcap Path Configuration
710          Information</a></dt>
711
712          <dt>11-8. <a href="#AEN1429">Example of Returned Printcap
713          Value</a></dt>
714
715          <dt>12-1. <a href="#AEN1437">Starting Screen</a></dt>
716
717          <dt>12-2. <a href="#AEN1442">Printcap Entry
718          Selection</a></dt>
719
720          <dt>12-3. <a href="#AEN1447">Add A Printer</a></dt>
721
722          <dt>12-4. <a href="#AEN1452">Option
723          Specification</a></dt>
724
725          <dt>12-5. <a href="#AEN1457">Advanced Options</a></dt>
726
727          <dt>12-6. <a href="#AEN1462"><b class=
728          "APPLICATION">ifhp</b> Options</a></dt>
729
730          <dt>12-7. <a href="#AEN1468">Saving Printcap
731          Entry</a></dt>
732
733          <dt>12-8. <a href="#AEN1473">Checkpc Results</a></dt>
734        </dl>
735      </div>
736
737      <div class="PREFACE">
738        <hr>
739
740        <h1><a name="AEN21">Preface</a></h1>
741
742        <p>A good cookbook will provide the reader not only with a
743        set of recipes that sound delicious but also with a set of
744        instructions that will allow novices to experts to prepare
745        them. Of course, there are cookbooks for novices, cookbooks
746        for experts, and then the gastronmic encyclopedias.</p>
747
748        <p>These <i class="EMPHASIS">Recipes for Printing</i> are a
749        collection of old favorites, not of the author, but of the
750        hundreds of users of <b class="APPLICATION">LPRng</b> and
751        other print spooling systems. They are not a complete
752        discussion of the printing <i class="EMPHASIS">haute
753        cuisine</i>, but deal more with the preparation of the <i
754        class="EMPHASIS">Minnesota Hot Dish</i>. As I find from
755        personal experience, you need to make a casserole for a
756        family dinner far more often than to prepare <i class=
757        "EMPHASIS">mijot&eacute;e de lentilles au lardons, dos de
758        poisson-chat r&ocirc;ti, au vinaigre d'herbes</i> for that
759        one-time special dinner.</p>
760
761        <p>The various test files, scripts and examples in this
762        document are also in the <b class="APPLICATION">LPRng</b>
763        distribution in the <tt class=
764        "FILENAME">/LPRng-xxx/UTILS</tt> directory.</p>
765
766        <p>Enjoy! Bon Appetite!</p>
767
768        <div class="SECT1">
769          <hr>
770
771          <h1 class="SECT1"><a name="AEN34">1.
772          Acknowledgements</a></h1>
773
774          <p>I would like to thank all of the <b class=
775          "APPLICATION">LPRng</b> users who so relentlessly tried
776          an incredible number of permutations and combinations
777          printers, software, and networks, and whose requests for
778          <i class="EMPHASIS">just one more feature</i> led to the
779          development of the <b class="APPLICATION">LPRng</b>
780          software.</p>
781        </div>
782
783        <div class="SECT1">
784          <hr>
785
786          <h1 class="SECT1"><a name="AEN40">2. Conventions</a></h1>
787
788          <p>Many examples will show commands run by ordinary or
789          privleged users. The prompt character will indicate the
790          user:</p>
791
792          <div class="INFORMALTABLE">
793            <a name="AEN43"></a>
794
795            <table border="0" class="CALSTABLE">
796              <thead>
797                <tr>
798                  <th align="LEFT" valign="TOP">User</th>
799
800                  <th align="LEFT" valign="TOP">Prompt</th>
801                </tr>
802              </thead>
803
804              <tbody>
805                <tr>
806                  <td align="LEFT" valign="TOP">Normal user</td>
807
808                  <td align="LEFT" valign="TOP"><tt class=
809                  "PROMPT">host {20} % su</tt></td>
810                </tr>
811
812                <tr>
813                  <td align="LEFT" valign="TOP"><tt class=
814                  "LITERAL">root</tt></td>
815
816                  <td align="LEFT" valign="TOP"><tt class=
817                  "PROMPT">host {2} #</tt></td>
818                </tr>
819              </tbody>
820            </table>
821          </div>
822
823          <p>Recipes and major examples will be show as:</p>
824
825          <div class="FIGURE">
826            <a name="AEN60"></a>
827
828            <p><b>Figure 1. lpq status</b></p>
829<pre class="SCREEN">
830    h110: {64} % lpq
831    Printer: lp@h110
832     Queue: no printable jobs in queue
833     Status: job 'cfA711h110.private' removed at 17:11:43.919
834     Filter_status: done at 17:11:43.823
835</pre>
836          </div>
837          <br>
838          <br>
839
840          <p>Smaller sets of code or commands will be shown as:</p>
841
842          <div class="INFORMALEXAMPLE">
843            <a name="AEN65"></a>
844<pre class="SCREEN">
845    Queue: no printable jobs in queue
846</pre>
847          </div>
848          <br>
849          <br>
850        </div>
851
852        <div class="SECT1">
853          <hr>
854
855          <h1 class="SECT1"><a name="AEN67">3. Disclaimer</a></h1>
856
857          <p>THIS DOCUMENTATION AND THE DESCRIBED SOFTWARE AND
858          PROCEDURES IS PROVIDED BY THE AUTHORS "AS IS" AND ANY
859          EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
860          TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
861          FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
862          SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
863          INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
864          (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
865          GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
866          BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
867          OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
868          TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
869          WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED
870          OF THE POSSIBILITY OF SUCH DAMAGE.</p>
871        </div>
872      </div>
873
874      <div class="CHAPTER">
875        <hr>
876
877        <h1><a name="AEN70">Chapter 1. Introduction - The Basics
878        and Variations</a></h1>
879
880        <div class="FIGURE">
881          <a name="FG1"></a>
882
883          <p><b>Figure 1-1. Print Spooler Architecture</b></p>
884
885          <div class="MEDIAOBJECT">
886            <p><img src="spooler.png"></p>
887          </div>
888        </div>
889
890        <p>The <b class="APPLICATION">LPRng</b> print spooling
891        system has the components shown in <a href="#FG1">Figure
892        1-1</a>. A program generates output and pipes it to the <b
893        class="APPLICATION">lpr</b> application or the <b class=
894        "APPLICATION">lpr</b> application is used to print a file.
895        The <b class="APPLICATION">lpr</b> application connects to
896        the <b class="APPLICATION">lpd</b> print server over a
897        network connection and then transfers the print job data
898        and print options. The <b class="APPLICATION">lpd</b>
899        server will store the job information <a href="#FG2">Figure
900        1-2</a> in a spool directory and when the output device is
901        available will transfer the job to the printing device.</p>
902
903        <p>Since the print job may not be in the appropriate format
904        for the ouput device a <b class="APPLICATION">filter</b>
905        program may be used to prepare the output data or perform
906        special operations on the output device. Alternatively, the
907        print job can be forwarded to another print spooler <a
908        href="#FG1">Figure 1-1</a>, transferred directly to a
909        TCP/IP network port.</p>
910
911        <div class="FIGURE">
912          <a name="FG2"></a>
913
914          <p><b>Figure 1-2. Configuration Files</b></p>
915
916          <div class="MEDIAOBJECT">
917            <p><img src="configfiles.png"></p>
918          </div>
919        </div>
920
921        <p>&#13;As shown in <a href="#FG2">Figure 1-2</a>, the <b
922        class="APPLICATION">LPRng</b> print spooler uses the <tt
923        class="FILENAME">/etc/printcap</tt>, <tt class=
924        "FILENAME">/etc/lpd.conf</tt>, and <tt class=
925        "FILENAME">/etc/lpd.perms</tt>, files to get its
926        operational parameters. The the <tt class=
927        "FILENAME">/etc/printcap</tt> file defines a set of spool
928        queues, each of which holds print jobs. The a print job
929        consists of a <i class="EMPHASIS">control</i> file (<tt
930        class="LITERAL">cfAnnnHHHHHHH</tt>) and one or more data
931        files (<tt class="LITERAL">dfAnnnHHHHHHH</tt> <tt class=
932        "LITERAL">dfBnnnHHHHHHH</tt>, etc); the control file
933        contains information such as the user name, file names, and
934        printing options, while the data files contain the data to
935        be printed.</p>
936
937        <div class="FIGURE">
938          <a name="FG3"></a>
939
940          <p><b>Figure 1-3. Printcap</b></p>
941<pre class="SCREEN">
942    # Common configuration information
943    .common:sd=/var/spool/lpd/%P
944      :sh:mx=0:force_localhost
945    
946    # forward to remote spooler
947    lp:cm=Default Printer
948     :tc=.common
949     :lp=raw@10.0.0.1
950           #  legacy - :rp=raw:rm=10.0.0.1
951    
952    # lp0 - open a device
953    lp0|aliasforlp0:cm=Parallel Port Printer:\
954      :tc=.common:lp=/dev/lpt0:
955    
956    # lp1 - open a network connection
957    lp1:tc=.common:lp=10.0.0.14%9100
958    
959    # lp2 - run a program
960    lp2:tc=.common:lp=|/usr/local/bin/smbprint
961</pre>
962        </div>
963
964        <p>&#13;The <tt class="FILENAME">/etc/printcap</tt> file
965        format is very simple in appearance but complex in
966        information. By convention, lines starting with <tt class=
967        "LITERAL">#</tt> are comments; a printcap entry starts with
968        the entry name followed by one or more <i class=
969        "EMPHASIS">aliases</i>, followed by options.</p>
970
971        <p>The <tt class="LITERAL">:tc</tt> option specifies a
972        printcap entry for inclusion; there can be more than one
973        entry and they are processed in order that they appear in
974        the <tt class="LITERAL">:tc</tt> list. The other options
975        are processed <i class="EMPHASIS">after</i> the <tt class=
976        "LITERAL">:tc</tt> list; this means that the printcap
977        options overide the ones from the <tt class=
978        "LITERAL">:tc</tt> list. If a entry name starts with a
979        period (<tt class="LITERAL">.</tt>), then the <b class=
980        "APPLICATION">LPRng</b> system uses it only for <tt class=
981        "LITERAL">:tc</tt> lists. This is similar to the use of <i
982        class="EMPHASIS">hidden</i> files, i.e. - files whose names
983        start with a period are not displayed by the <b class=
984        "APPLICATION">ls</b> command.</p>
985
986        <p>&#13;</p>
987
988        <div class="FIGURE">
989          <a name="FG4"></a>
990
991          <p><b>Figure 1-4. lpd.conf Defaults File</b></p>
992<pre class="SCREEN">
993    # Purpose: always print banner, ignore lpr -h option
994    #   default ab@ (FLAG off)
995    # Purpose: query accounting server when connected
996    #   default achk@ (FLAG off)
997    # Purpose: accounting at end (see also af, la, ar, as)
998    #   default ae=jobend $H $n $P $k $b $t  (STRING)
999    # Purpose: name of accounting file (see also la, ar)
1000    #   default af=acct  (STRING)
1001    
1002    # Purpose: use long job number (0 - 999999) when a job is submitted
1003    #   default longnumber@ (FLAG off)
1004    longnumber
1005</pre>
1006        </div>
1007        &#13;<br>
1008        <br>
1009
1010        <p>The <tt class="FILENAME">/etc/lpd.conf</tt> file can be
1011        used to override the set of default values for the print
1012        spooler or other printing applications. By the way, all of
1013        the <b class="APPLICATION">LPRng</b> options and their
1014        default values are defined in this file in the
1015        comments.</p>
1016
1017        <div class="FIGURE">
1018          <a name="FG5"></a>
1019
1020          <p><b>Figure 1-5. lpd.perm Permissions File</b></p>
1021<pre class="SCREEN">
1022    ACCEPT SERVICE=C SERVER REMOTEUSER=root,papowell
1023    ACCEPT SERVICE=C LPC=lpd,status,printcap
1024    REJECT SERVICE=C
1025    ACCEPT SERVICE=M SAMEHOST SAMEUSER
1026    ACCEPT SERVICE=M SERVER REMOTEUSER=root
1027    REJECT SERVICE=M
1028    DEFAULT ACCEPT
1029</pre>
1030        </div>
1031
1032        <p>The <tt class="FILENAME">/etc/lpd.perms</tt> file (<a
1033        href="#FG5">Figure 1-5</a>) is used by <b class=
1034        "APPLICATION">lpd</b> to determine who is allowed to
1035        perform various operations. The format of this file is
1036        modelled on that of a <i class="EMPHASIS">packet
1037        filter</i>. When a request is made, the file is scanned for
1038        matches; each match sets a success or fail condition. The
1039        success or fail of the last match (or the last default
1040        value) will determine whether or not to perform the
1041        operation.</p>
1042
1043        <div class="FIGURE">
1044          <a name="FG6"></a>
1045
1046          <p><b>Figure 1-6. Clients and Configuration Files</b></p>
1047
1048          <div class="MEDIAOBJECT">
1049            <p><img src="clients.png"></p>
1050          </div>
1051        </div>
1052
1053        <p>The <b class="APPLICATION">LPRng</b> client applications
1054        <b class="APPLICATION">lpr</b>, <b class=
1055        "APPLICATION">lprm</b>, <b class="APPLICATION">lpq</b>, and
1056        <b class="APPLICATION">lpc</b> use the <tt class=
1057        "FILENAME">/etc/lpd.conf</tt>, <tt class=
1058        "FILENAME">/etc/printcap</tt> and <tt class=
1059        "LITERAL">${HOME}/.printap</tt> files (if they exist) (<a
1060        href="#FG6">Figure 1-6</a>). The values in the <tt class=
1061        "LITERAL">${HOME}/.printcap</tt> file are used to override
1062        the values in the <tt class="FILENAME">/etc/printcap</tt>
1063        file, and the first printcap entry in the <tt class=
1064        "LITERAL">${HOME}/.printap</tt> file becomes the default
1065        printer for the user (see <a href="#FG7">Figure
1066        1-7</a>).</p>
1067
1068        <div class="FIGURE">
1069          <a name="FG7"></a>
1070
1071          <p><b>Figure 1-7. ${HOME}/.printcap Information</b></p>
1072<pre class="SCREEN">
1073    # force your default printer
1074    #  - forces first entry to be lp_out
1075    lp_out:
1076    
1077    # send everything to your secret server
1078    *:lp=%P@secret_server:force_localhost@
1079    
1080    # combine the two above:
1081    lp|*:lp=%P@secret_server:force_localhost@
1082    
1083    # and of course, you can specify extra lpr options
1084    # for those special purpose printers and total abuse
1085    landscape:lpr= -Zlandscape -Plp
1086</pre>
1087        </div>
1088
1089        <div class="SECT1">
1090          <hr>
1091
1092          <h1 class="SECT1"><a name="AEN160">1.1. Checking the
1093          Printing System</a></h1>
1094
1095          <div class="FIGURE">
1096            <a name="FG8"></a>
1097
1098            <p><b>Figure 1-8. Using checkpc</b></p>
1099<pre class="SCREEN">
1100    h110: {1} % su
1101    Password:
1102    h110# checkpc
1103    h110# checkpd -V
1104    LPRng-3.7.10, Copyright 1988-2001 Patrick Powell, &lt;papowell@lprng.com&gt;
1105    Checking for configuration files '/etc/lpd.conf'
1106      found '/etc/lpd.conf', mod 0100644
1107    Checking for printcap files '/etc/printcap'
1108      found '/etc/printcap', mod 0100644
1109     DaemonUID 1, DaemonGID 1
1110    Using Config file '/etc/lpd.conf'
1111    LPD lockfile '/var/run/lpd.515'
1112    ...
1113    Checking printer 'lp'
1114     Checking directory: '/var/spool/lpd/lp'
1115       directory '/var'
1116       directory '/var/spool'
1117       directory '/var/spool/lpd'
1118       directory '/var/spool/lpd/lp'
1119      checking 'control.lp' file
1120      checking 'status.lp' file
1121      checking 'status' file
1122      checking 'log' file
1123      checking 'acct' file
1124</pre>
1125          </div>
1126
1127          <p>The <b class="APPLICATION">checkpc</b> utility will
1128          read and parse the printcap file. It will report a
1129          zillion errors if something is wrong.</p>
1130        </div>
1131
1132        <div class="SECT1">
1133          <hr>
1134
1135          <h1 class="SECT1"><a name="AEN168">1.2. Fixing the
1136          Problems</a></h1>
1137
1138          <div class="FIGURE">
1139            <a name="FG9"></a>
1140
1141            <p><b>Figure 1-9. Using checkpc -f</b></p>
1142<pre class="SCREEN">
1143    h110: {1} % checkpc
1144    Warning -  bad directory - /var/spool/lpd/lp
1145    Warning -   Printer_DYN 'lp' spool dir '/var/spool/lpd/lp' needs fixing
1146    Warning -  bad directory - /var/spool/lpd/lp0
1147    Warning -   Printer_DYN 'lp0' spool dir '/var/spool/lpd/lp0' needs fixing
1148    h110: {2} % su
1149    Password:
1150    h110# checkpc -f
1151    Warning -   changing ownership '/var/spool/lpd/lp' to 1/1
1152    Warning -   changing ownership '/var/spool/lpd/lp' to 1/1
1153    Warning -   changing ownership '/var/spool/lpd/lp0' to 1/1
1154    Warning -   changing ownership '/var/spool/lpd/lp0' to 1/1
1155    h110# exit
1156    h110: {3} % checkpc
1157    h110: {4} % checkpc
1158</pre>
1159          </div>
1160
1161          <p>The <tt class="LITERAL">checkpc -f</tt> (<tt class=
1162          "LITERAL">-f</tt> for <i class="EMPHASIS">fix</i>) will
1163          make <b class="APPLICATION">checkpc</b> attempt create
1164          missing files, set permissions, and take basic corrective
1165          actions. If it fails, then you have probably a <i class=
1166          "EMPHASIS">very</i> bad <tt class=
1167          "FILENAME">/etc/printcap</tt> file.</p>
1168        </div>
1169      </div>
1170
1171      <div class="CHAPTER">
1172        <hr>
1173
1174        <h1><a name="AEN181">Chapter 2. Simple Spooling</a></h1>
1175
1176        <p>This section covers the basic facilities that you will
1177        probably encounter when trying to set up a print queue. We
1178        will start with a basic print queue and then run through
1179        the setup steps.</p>
1180
1181        <div class="FIGURE">
1182          <a name="AEN184"></a>
1183
1184          <p><b>Figure 2-1. Basic Printcap Entry</b></p>
1185<pre class="SCREEN">
1186    # Common configuration information
1187    .common:sd=/var/spool/lpd/%P
1188      :sh:mx=0:force_localhost
1189    lp:cm=Default Printer, Forward to remote
1190     :tc=.common
1191     :lp=raw@10.0.0.1
1192    
1193    # lp0 - open a device
1194    lp0:cm=Parallel Port Printer
1195      :tc=.common:lp=/dev/lpt0:
1196</pre>
1197        </div>
1198
1199        <div class="SECT1">
1200          <hr>
1201
1202          <h1 class="SECT1"><a name="AEN187">2.1. Setting Up The
1203          Print Queues</a></h1>
1204
1205          <div class="FIGURE">
1206            <a name="AEN189"></a>
1207
1208            <p><b>Figure 2-2. Run checkpc</b></p>
1209<pre class="SCREEN">
1210    h110: {1} % checkpc
1211    Warning -  bad directory - /var/spool/lpd/lp
1212    Warning -   Printer_DYN 'lp' spool dir '/var/spool/lpd/lp' needs fixing
1213    Warning -  bad directory - /var/spool/lpd/lp0
1214    Warning -   Printer_DYN 'lp0' spool dir '/var/spool/lpd/lp0' needs fixing
1215    h110: {2} % su
1216    Password:
1217    h110# checkpc -f
1218    Warning -   changing ownership '/var/spool/lpd/lp' to 1/1
1219    Warning -   changing ownership '/var/spool/lpd/lp' to 1/1
1220    Warning -   changing ownership '/var/spool/lpd/lp0' to 1/1
1221    Warning -   changing ownership '/var/spool/lpd/lp0' to 1/1
1222    h110# exit
1223    h110: {3} % checkpc
1224    h110: {4} % checkpc
1225</pre>
1226          </div>
1227
1228          <p>First, you run <tt class="LITERAL">checkpc -f</tt>.
1229          This will tell you if something is wrong with the
1230          printcap.</p>
1231
1232          <div class="FIGURE">
1233            <a name="AEN194"></a>
1234
1235            <p><b>Figure 2-3. Check for Running Server</b></p>
1236<pre class="SCREEN">
1237    h110: {5} % lpc lpd
1238    Printer 'lp@localhost' - cannot open connection - Connection refused
1239    Make sure the remote host supports the LPD protocol
1240    h110: {6} % su
1241    Password:
1242    h110# lpd
1243    h110# lpc lpd
1244    lpd server pid 6418 on h110.private
1245    h110# exit
1246    exit
1247    h110: {7} % lpc lpd
1248    lpd server pid 6418 on h110.private
1249</pre>
1250          </div>
1251
1252          <p>Next, you make sure the <b class="APPLICATION">lpd</b>
1253          server is running, and if it is not, then you restart
1254          it.</p>
1255
1256          <p>&#13;</p>
1257
1258          <div class="FIGURE">
1259            <a name="AEN200"></a>
1260
1261            <p><b>Figure 2-4. Run lpq</b></p>
1262<pre class="SCREEN">
1263    h110: {373} % lpq -a
1264    Printer: lp@h110
1265     Queue: no printable jobs in queue
1266    Printer: lp0@h110
1267     Queue: no printable jobs in queue
1268</pre>
1269          </div>
1270          &#13;<br>
1271          <br>
1272
1273          <p>You now make sure that you can get the print queue
1274          status.</p>
1275
1276          <div class="FIGURE">
1277            <a name="AEN205"></a>
1278
1279            <p><b>Figure 2-5. Run lpc</b></p>
1280<pre class="SCREEN">
1281    h110: {374} % lpc stop lp lp0
1282    Printer: lp@h110
1283    lp@h110.private: stopped
1284    Printer: lp0@h110
1285    lp0@h110.private: stopped
1286    h110: {375} % lpq -a
1287    Printer: lp@h110 (printing disabled)
1288     Queue: no printable jobs in queue
1289    Printer: lp0@h110 (printing disabled)
1290     Queue: no printable jobs in queue
1291</pre>
1292          </div>
1293
1294          <p>Use <b class="APPLICATION">lpc</b> to disable
1295          printing.</p>
1296
1297          <p>&#13;</p>
1298
1299          <div class="FIGURE">
1300            <a name="AEN212"></a>
1301
1302            <p><b>Figure 2-6. Run lpr</b></p>
1303<pre class="SCREEN">
1304    h110: {376} % echo hi &gt;/tmp/hi
1305    h110: {377} % lpr /tmp/hi
1306    h110: {378} % lpq
1307    Printer: lp@h110 (printing disabled)
1308     Queue: 1 printable job
1309     Server: no server active
1310     Rank   Owner/ID          Class Job Files         Size Time
1311    1      papowell@h110+445    A   445 /tmp/hi          3 17:40:51
1312    h110: {379} % lpr -Plp0 /tmp/hi
1313    h110: {380} % lpq -Plp0
1314    Printer: lp0@h110 (printing disabled)
1315     Queue: 1 printable job
1316     Server: no server active
1317     Rank   Owner/ID          Class Job Files         Size Time
1318    1      papowell@h110+449    A   449 /tmp/hi          3 17:41:05
1319</pre>
1320          </div>
1321          <br>
1322          <br>
1323
1324          <p>Now try spooling a job.</p>
1325
1326          <div class="FIGURE">
1327            <a name="AEN217"></a>
1328
1329            <p><b>Figure 2-7. Run lprm</b></p>
1330<pre class="SCREEN">
1331    h110: {381} % lprm
1332    Printer lp@h110:
1333      checking perms 'papowell@h110+445'
1334      dequeued 'papowell@h110+445'
1335    h110: {382} % lprm -Plp0
1336    Printer lp0@h110:
1337      checking perms 'papowell@h110+449'
1338      dequeued 'papowell@h110+449'
1339</pre>
1340          </div>
1341
1342          <p>Now try removing a job.</p>
1343
1344          <div class="FIGURE">
1345            <a name="AEN222"></a>
1346
1347            <p><b>Figure 2-8. Enable Printing</b></p>
1348<pre class="SCREEN">
1349    h110: {383} % lpc enable lp lp0
1350    Printer: lp@h110
1351    lp@h110.private: enabled
1352    Printer: lp0@h110
1353    lp0@h110.private: enabled
1354</pre>
1355          </div>
1356
1357          <p>Finally, enable printing.</p>
1358        </div>
1359
1360        <div class="SECT1">
1361          <hr>
1362
1363          <h1 class="SECT1"><a name="AEN226">2.2. Diagnostics for
1364          Spooling Problems</a></h1>
1365
1366          <div class="FIGURE">
1367            <a name="AEN228"></a>
1368
1369            <p><b>Figure 2-9. Using lpr -V</b></p>
1370<pre class="SCREEN">
1371    h110: {388} % lpr -V /tmp/hi
1372    LPRng-3.7.10, Copyright 1988-2001 Patrick Powell, &lt;papowell@lprng.com&gt;
1373    sending job 'papowell@h110+29' to lp@localhost
1374    connecting to 'localhost', attempt 1
1375    connected to 'localhost'
1376    requesting printer lp@localhost
1377    sending control file 'cfA029h110.private' to lp@localhost
1378    completed sending 'cfA029h110.private' to lp@localhost
1379    sending data file 'dfA029h110.private' to lp@localhost
1380    completed sending 'dfA029h110.private' to lp@localhost
1381    done job 'papowell@h110+29' transfer to lp@localhost
1382</pre>
1383          </div>
1384
1385          <p>The first line of defense is to see what is happening
1386          when you try to spool a job. The <tt class="LITERAL">lpr
1387          -V</tt> (<tt class="LITERAL">-V</tt> for <i class=
1388          "EMPHASIS">Verbose</i>) will show a simple high level
1389          trace.</p>
1390
1391          <div class="FIGURE">
1392            <a name="AEN236"></a>
1393
1394            <p><b>Figure 2-10. The lpr Options</b></p>
1395<pre class="SCREEN">
1396    h110: {389} % lpr -=
1397    lpr: Illegal option '='
1398    Usage: lpr [-Pprinter[@host]] [-A] [-B] [-Cclass] [-Fformat] [-G] [-Jinfo]
1399       [-(K|#)copies] [-Q] [-Raccountname]  [-Ttitle]  [-Uuser[@host]] [-V]
1400       [-Zoptions] [-b] [-m mailaddr] [-h] [-i indent] [-l] [-w width ] [-r]
1401       [-Ddebugopt ] [--] [ filenames ...  ]
1402     -A          - use authentication specified by AUTH environment variable
1403     -B          - filter files and reduce job to single file before sending
1404     -C class    - job class
1405     -D debugopt - debugging flags
1406     -F format   - job format
1407       -b,-l        - binary or literal format
1408        c,d,f,g,l,m,p,t,v are also format options
1409     -G          - filter individual job files before sending
1410     -J info     - banner and job information
1411     -K copies, -# copies   - number of copies
1412     -P printer[@host] - printer on host
1413     -Q          - put 'queuename' in control file
1414     -Raccntname - accounting information
1415     -T title    - title for 'pr' (-p) formatting
1416     -U username - override user name (restricted)
1417     -V          - Verbose information during spooling
1418     -X path     - user specified filter for job files
1419     -Y          - connect and send to TCP/IP port (direct mode)
1420     -Z options  - options to pass to filter
1421     -h          - no header or banner page
1422     -i indent   - indentation
1423     -k          - do not use tempfile when sending to server
1424     -m mailaddr - mail final status to mailaddr
1425     -r          - remove files after spooling
1426     -w width    - width to use
1427     --          - end of options, files follow
1428     filename '-'  reads from STDIN
1429     PRINTER, LPDEST, NPRINTER, NGPRINTER environment variables set default printer.
1430    LPRng-3.7.10, Copyright 1988-2001 Patrick Powell, &lt;papowell@lprng.com&gt;
1431</pre>
1432          </div>
1433
1434          <p>Use the <tt class="LITERAL">-=</tt> option to see the
1435          available options.</p>
1436
1437          <div class="FIGURE">
1438            <a name="AEN242"></a>
1439
1440            <p><b>Figure 2-11. Debug Options</b></p>
1441<pre class="SCREEN">
1442    h110: {392} % lpr -D=
1443    debug usage: -D [ num | flag=num | flag=str | flag | flag@ | flag+N ]*
1444      flags recognized: network[+N,@], database[+N,@], lpr[+N,@],
1445       lpc[+N,@], lprm[+N,@], lpq[+N,@], log[+N,@],
1446       test=num
1447</pre>
1448          </div>
1449
1450          <p>The <tt class="LITERAL">-D=</tt> option shows the
1451          debugging flags available.</p>
1452
1453          <div class="FIGURE">
1454            <a name="AEN247"></a>
1455
1456            <p><b>Figure 2-12. The lpr -D1 Output</b></p>
1457<pre class="SCREEN">
1458    h110: {395} % lpr -D1 /tmp/hi &gt;&amp;/tmp/x
1459    2001-10-18-05:29:05 [8052]  Initialize: /dev/null fd 3
1460    2001-10-18-05:29:05 [8052]  initsetproctitle: using builtin
1461    2001-10-18-05:29:05 [8052] lpr  Setup_uid: OriginalEUID 0, OriginalRUID 1001
1462    2001-10-18-05:29:05 [8052] lpr  Setup_uid: OriginalEGID 1001, OriginalRGID 1001
1463    2001-10-18-05:29:05.761 [8052] lpr  Setup_configuration: starting, Allow_getenv 0
1464    2001-10-18-05:29:05.761 [8052] lpr  Setup_configuration: Configuration file '/etc/lpd.conf'
1465    2001-10-18-05:29:05.761 [8052] lpr  Setup_configuration: Require_configfiles_DYN '1'
1466    2001-10-18-05:29:05.761 [8052] lpr  Get_config: required '1', '/etc/lpd.conf'
1467    2001-10-18-05:29:05.762 h110 [8052] lpr
1468       Get_local_host: ShortHost_FQDN=h110, FQDNHost_FQDN=h110.private
1469    2001-10-18-05:29:05.763 h110 [8052] lpr
1470       Is_server 0, DaemonUID 1, DaemonGID 1, UID 0, EUID 0, GID 1001, EGID 1001
1471    2001-10-18-05:29:05.763 h110 [8052] lpr
1472       Setup_configuration: Host 'h110.private', ShortHost 'h110', user 'papowell'
1473    ...
1474</pre>
1475          </div>
1476
1477          <p>The <b class="APPLICATION">lpr</b> <tt class=
1478          "LITERAL">-D1</tt> (diagnostic level 1) shows a summary
1479          of the various steps taken to send the job. If you want
1480          more detail, try <b class="APPLICATION">lpr</b> <tt
1481          class="LITERAL">-D2</tt>; or even <b class=
1482          "APPLICATION">lpr</b> <tt class="LITERAL">-D3</tt>;.</p>
1483
1484          <div class="FIGURE">
1485            <a name="AEN258"></a>
1486
1487            <p><b>Figure 2-13. Using lpr -Dnetwork</b></p>
1488<pre class="SCREEN">
1489    h110: {400} % lpr -Dnetwork /tmp/hi
1490    lp: getconnection: START host localhost, timeout 10, connection_type 1
1491    lp: getconnection: fqdn found localhost.my.domain, h_addr_list count 1
1492    lp: Link_dest_port_num: port 515 = 515
1493    lp: getconnection: AGAIN port 808, min 512, max 1023, count 0, connects 0
1494    lp: Link_dest_port_num: port 515 = 515
1495    lp: getconnection: sock 3, src ip 127.0.0.1, port 808
1496    lp: getconnection: dest ip 127.0.0.1, port 515
1497    lp: getconnection: connection to 'localhost' socket 3, errormsg 'No Error'
1498    lp: Link_send: host 'localhost' socket 3, timeout 6000
1499    lp: Link_send: str '^Blp
1500    ', count 4, ack 0xbfbfc3d0
1501    lp: Link_send: final status NO ERROR
1502    lp: Link_send: host 'localhost' socket 3, timeout 6000
1503    lp: Link_send: str '^B142 cfA065h110.private
1504    ', count 24, ack 0xbfbfbf90
1505    lp: Link_send: final status NO ERROR
1506    lp: Link_send: host 'localhost' socket 3, timeout 6000
1507    lp: Link_send: str 'Hh110.private
1508    Ppapowell
1509    J/tmp/hi
1510    CA
1511    Lpapowell
1512    Apapowell@h110+65
1513    D2001-10-18-05:34:18.939
1514    Qlp
1515    N/tmp/hi
1516    fdfA065h110.private
1517    UdfA065h110.private
1518    ', count 143, ack 0xbfbfbf90
1519    lp: Link_send: final status NO ERROR
1520    lp: Link_send: host 'localhost' socket 3, timeout 6000
1521    lp: Link_send: str '^C3 dfA065h110.private
1522    ', count 22, ack 0xbfbfbf24
1523    lp: Link_send: final status NO ERROR
1524    lp: Link_send: host 'localhost' socket 3, timeout 6000
1525    lp: Link_send: str '', count 1, ack 0xbfbfbf24
1526    lp: Link_send: final status NO ERROR
1527</pre>
1528          </div>
1529
1530          <p>The <b class="APPLICATION">lpr</b> <tt class=
1531          "LITERAL">-Dnetwork</tt> (network diagnostic level 1)
1532          shows the network operations performed by <b class=
1533          "APPLICATION">lpr</b>. If you want more detail, try <b
1534          class="APPLICATION">lpr</b> <tt class=
1535          "LITERAL">-Dnetwork+2</tt> or even <b class=
1536          "APPLICATION">lpr</b> <tt class=
1537          "LITERAL">-Dnetwork+3</tt>.</p>
1538
1539          <div class="FIGURE">
1540            <a name="AEN270"></a>
1541
1542            <p><b>Figure 2-14. Debugging lpq</b></p>
1543<pre class="SCREEN">
1544    h110: {1} % lpq -=
1545    lpq: Illegal option '='
1546    usage: lpq [-aAclV] [-Ddebuglevel] [-Pprinter] [-tsleeptime]
1547      -A           - use authentication specified by AUTH environment variable
1548      -a           - all printers
1549      -c           - clear screen before update
1550      -l           - increase (lengthen) detailed status information
1551                     additional l flags add more detail.
1552      -L           - maximum detailed status information
1553      -n linecount - linecount lines of detailed status information
1554      -Ddebuglevel - debug level
1555      -Pprinter    - specify printer
1556      -s           - short (summary) format
1557      -tsleeptime  - sleeptime between updates
1558      -V           - print version information
1559    
1560    h110: {2} % lpq -D1
1561    2001-10-18-05:39:09 [8090]  Initialize: /dev/null fd 3
1562    2001-10-18-05:39:09 [8090]  initsetproctitle: using builtin
1563    2001-10-18-05:39:09 [8090] lpq  Setup_uid: OriginalEUID 0, OriginalRUID 1001
1564    ...
1565    
1566    h110: {3} % lpq -Dnetwork
1567    lp: getconnection: START host localhost, timeout 10, connection_type 1
1568    lp: getconnection: fqdn found localhost.my.domain, h_addr_list count 1
1569    lp: Link_dest_port_num: port 515 = 515
1570    lp: getconnection: AGAIN port 862, min 512, max 1023, count 0, connects 0
1571    lp: Link_dest_port_num: port 515 = 515
1572    lp: getconnection: sock 3, src ip 127.0.0.1, port 862
1573    ...
1574</pre>
1575          </div>
1576
1577          <p>The <b class="APPLICATION">lpq</b>, <b class=
1578          "APPLICATION">lprm</b>, and <b class=
1579          "APPLICATION">lpc</b> applications also support the <tt
1580          class="LITERAL">-=</tt> and <tt class="LITERAL">-D</tt>
1581          (debug) options.</p>
1582        </div>
1583
1584        <div class="SECT1">
1585          <hr>
1586
1587          <h1 class="SECT1"><a name="AEN280">2.3. What Went Wrong
1588          With My Job?</a></h1>
1589
1590          <div class="FIGURE">
1591            <a name="AEN282"></a>
1592
1593            <p><b>Figure 2-15. Basic lpq Information</b></p>
1594<pre class="SCREEN">
1595    
1596    h110: {1} % lpr /tmp/hi
1597    h110: {1} % lpq
1598    Printer: lp@h110
1599     Queue: 1 printable job
1600     Server: pid 8741 active
1601     Unspooler: pid 8742 active
1602     Status: processing 'dfA740h110.private', size 3, format 'f',
1603        IF filter 'ifhp' at 08:16:58.465
1604     Filter_status: code = 10003, 'Warming Up' at 08:17:02.045
1605     Rank   Owner/ID         Class Job Files      Size Time
1606    active papowell@h110+740  A    740 /tmp/hi       3 08:16:58
1607</pre>
1608          </div>
1609
1610          <p>The first thing to do is check the status of your job
1611          with <b class="APPLICATION">lpq</b>. This will show the
1612          current jobs in the queue and <b class=
1613          "APPLICATION">lpd</b> server. The <tt class=
1614          "LITERAL">Server</tt> value is the process that is
1615          responsible for sending jobs to the printer. It starts
1616          the <tt class="LITERAL">Unspooler</tt> process that does
1617          the actual transfer to the remote system. Each time a job
1618          is processed a new <tt class="LITERAL">Unspooler</tt>
1619          process is created. The <tt class="LITERAL">Server</tt>
1620          process stays active until there is no further work to be
1621          done for the print queue.</p>
1622
1623          <div class="FIGURE">
1624            <a name="AEN293"></a>
1625
1626            <p><b>Figure 2-16. Using the lpq -l Option</b></p>
1627<pre class="SCREEN">
1628    h110: {2} % lpq -l
1629    Printer: lp@h110
1630     Queue: 1 printable job
1631     Server: pid 8741 active
1632     Unspooler: pid 8742 active
1633     Status: printing job 'papowell@h110+740' at 08:16:58.465
1634     Status: processing 'dfA740h110.private', size 3, format 'f',
1635         IF filter 'ifhp' at 08:16:58.465
1636     Filter_status: getting end using 'pjl job/eoj' at 08:16:59.902
1637     Filter_status: code = 10003, 'Warming Up' at 08:17:02.045
1638     Rank   Owner/ID          Class Job Files      Size Time
1639    active papowell@h110+740  A     740 /tmp/hi       3 08:16:58
1640    h110: {3} % lpq -lll
1641    Printer: lp@h110
1642     Queue: 1 printable job
1643     Server: pid 8741 active
1644     Unspooler: pid 8742 active
1645     Status: accounting at start at 08:16:58.455
1646     Status: opening device 'h14%9100' at 08:16:58.455
1647     Status: printing job 'papowell@h110+740' at 08:16:58.465
1648     Status: processing 'dfA740h110.private', size 3, format 'f',
1649         IF filter 'ifhp' at 08:16:58.465
1650     Filter_status: data sent at 08:16:59.902
1651     Filter_status: sent job file at 08:16:59.902
1652     Filter_status: getting end using 'pjl job/eoj' at 08:16:59.902
1653     Filter_status: code = 10003, 'Warming Up' at 08:17:02.045
1654     Rank   Owner/ID          Class Job Files      Size Time
1655    active papowell@h110+740  A     740 /tmp/hi       3 08:16:58
1656</pre>
1657          </div>
1658
1659          <p>The <b class="APPLICATION">lpq</b> <tt class=
1660          "LITERAL">-l</tt> (<i class="EMPHASIS">longer</i>) option
1661          increases the number of <tt class="LITERAL">Status</tt>
1662          and <tt class="LITERAL">Filter_status</tt> lines shown.
1663          These lines come from the <tt class=
1664          "LITERAL">status.%P</tt> and <tt class=
1665          "LITERAL">status</tt> files in the spool queue. Adding
1666          more <tt class="LITERAL">-l</tt> options increases the
1667          amount of status shown.</p>
1668
1669          <div class="FIGURE">
1670            <a name="AEN306"></a>
1671
1672            <p><b>Figure 2-17. Using the lpq -L Option</b></p>
1673<pre class="SCREEN">
1674    
1675    h110: {4} % lpq -L
1676    Printer: lp@h110
1677     Queue: 1 printable job
1678     Server: pid 8741 active
1679     Unspooler: pid 8742 active
1680     Status: waiting for subserver to exit at 08:16:58.451
1681     Status: subserver pid 8742 starting at 08:16:58.455
1682     Status: accounting at start at 08:16:58.455
1683     Status: opening device 'h14%9100' at 08:16:58.455
1684     Status: printing job 'papowell@h110+740' at 08:16:58.465
1685     Status: processing 'dfA740h110.private', size 3, format 'f',
1686         IF filter 'ifhp' at 08:16:58.465
1687     .....
1688    
1689     Filter_status: decoded job type 'PCL' at 08:16:59.901
1690     Filter_status: job type 'PCL' at 08:16:59.901
1691     Filter_status: transferring 3 bytes at 08:16:59.902
1692     Filter_status: 100 percent done at 08:16:59.902
1693     Filter_status: data sent at 08:16:59.902
1694     Filter_status: sent job file at 08:16:59.902
1695     Filter_status: getting end using 'pjl job/eoj' at 08:16:59.902
1696     Filter_status: code = 10003, 'Warming Up' at 08:17:02.045
1697     .....
1698    
1699     Rank   Owner/ID          Class Job Files     Size Time
1700    active papowell@h110+740    A   740 /tmp/hi      3 08:16:58
1701</pre>
1702          </div>
1703
1704          <p>If you want to see <i class="EMPHASIS">LOTS</i> of
1705          status, use <tt class="LITERAL">lpq -L</tt>, which shows
1706          all the avilable status information.</p>
1707
1708          <div class="FIGURE">
1709            <a name="AEN313"></a>
1710
1711            <p><b>Figure 2-18. Job Completion</b></p>
1712<pre class="SCREEN">
1713    h110: {5} % lpq
1714    Printer: lp@h110
1715     Queue: no printable jobs in queue
1716     Status: job 'cfA740h110.private' removed at 08:18:07.776
1717     Filter_status: done at 08:18:07.756
1718    h110: {6} % lpq -lll
1719    Printer: lp@h110
1720     Queue: no printable jobs in queue
1721     Status: printing job 'papowell@h110+740' at 08:16:58.465
1722     Status: processing 'dfA740h110.private', size 3, format 'f',
1723         IF filter 'ifhp' at 08:16:58.465
1724     Status: IF filter 'ifhp' filter finished at 08:18:07.757
1725     Status: printing finished at 08:18:07.757
1726     Status: accounting at end at 08:18:07.774
1727     Status: finished 'papowell@h110+740', status 'JSUCC' at 08:18:07.774
1728     Status: subserver pid 8742 exit status 'JSUCC' at 08:18:07.775
1729     Status: lp@h110.private: job 'cfA740h110.private' printed at 08:18:07.775
1730     Status: job 'cfA740h110.private' removed at 08:18:07.776
1731     Filter_status: transferring 3 bytes at 08:16:59.902
1732     Filter_status: 100 percent done at 08:16:59.902
1733     Filter_status: data sent at 08:16:59.902
1734     Filter_status: sent job file at 08:16:59.902
1735     Filter_status: getting end using 'pjl job/eoj' at 08:16:59.902
1736     Filter_status: code = 10003, 'Warming Up' at 08:17:02.045
1737     Filter_status: end of job detected at 08:18:06.457
1738     Filter_status: pagecounter 105341 after 1 attempts at 08:18:07.756
1739     Filter_status: pagecounter 105341, pages 1 at 08:18:07.756
1740     Filter_status: done at 08:18:07.756
1741</pre>
1742          </div>
1743
1744          <p>When your job is finished, you can use the <tt class=
1745          "LITERAL">lpq -lll</tt> options to see the final results
1746          of processing the job.</p>
1747
1748          <div class="FIGURE">
1749            <a name="AEN318"></a>
1750
1751            <p><b>Figure 2-19. Summary Status Displays</b></p>
1752<pre class="SCREEN">
1753    h110: {7} % lpq -s
1754    lp@h110 0 jobs
1755    h110: {239} % lpq -s -a
1756    lp@h110 0 jobs
1757    lp0@h110 0 jobs (printing disabled)
1758    h110: {8} % lpc status
1759     Printer    Printing Spooling Jobs  Server Subserver Redirect Status/(Debug)
1760    lp@h110      enabled  enabled    0    none    none
1761    h110: {9} % lpc status all
1762     Printer    Printing Spooling Jobs  Server Subserver Redirect Status/(Debug)
1763    lp@h110      enabled  enabled    0    none    none
1764    lp0@h110    disabled  enabled    0    none    none
1765    h110: {10} % exit
1766</pre>
1767          </div>
1768
1769          <p>The <tt class="LITERAL">lpq -s</tt> (<i class=
1770          "EMPHASIS">short</i> status) shows a single summary line
1771          for status. Adding the <tt class="LITERAL">-a</tt> (<i
1772          class="EMPHASIS">all</i> queues) will print information
1773          for all the print queues.</p>
1774
1775          <p>The <tt class="LITERAL">lpc status</tt> command
1776          queries the <b class="APPLICATION">lpd</b> server and
1777          reports the status of the queues operated by the <b
1778          class="APPLICATION">lpd</b> server. The <tt class=
1779          "LITERAL">lpd status all</tt> will show the status of all
1780          the print queues.</p>
1781        </div>
1782
1783        <div class="SECT1">
1784          <hr>
1785
1786          <h1 class="SECT1"><a name="AEN331">2.4. Diagnostics for
1787          <b class="APPLICATION">lpd</b> Problems</a></h1>
1788
1789          <div class="FIGURE">
1790            <a name="AEN334"></a>
1791
1792            <p><b>Figure 2-20. lpd Options</b></p>
1793<pre class="SCREEN">
1794    h110# lpd -=
1795    lpd: Illegal option '='
1796    usage: lpd [-FV] [-D dbg] [-L log]
1797     Options
1798     -D dbg      - set debug level and flags
1799                     Example: -D10,remote=5
1800                     set debug level to 10, remote flag = 5
1801     -F          - run in foreground, log to STDERR
1802                   Example: -D10,remote=5
1803     -L logfile  - append log information to logfile
1804     -V          - show version info
1805    h110# lpd -D=
1806    debug usage: -D [ num | flag=num | flag=str | flag | flag@ | flag+N ]*
1807      flags recognized: network[+N,@], database[+N,@], lpr[+N,@],
1808       lpc[+N,@], lprm[+N,@], lpq[+N,@], log[+N,@],
1809       test=num
1810</pre>
1811          </div>
1812
1813          <p>The <b class="APPLICATION">lpd</b> server can be
1814          started in debug mode. However, the amount of information
1815          produced can be overwhelming. If you need to determine
1816          what is happening during initial connection, then you
1817          will have to do this.</p>
1818
1819          <div class="FIGURE">
1820            <a name="AEN340"></a>
1821
1822            <p><b>Figure 2-21. Using lpd Debug Options</b></p>
1823<pre class="SCREEN">
1824    h110# lpd
1825    h110# lpd -F -D1
1826    2001-10-18-05:56:55 [8156] lpd  Initialize: starting
1827    ...
1828    2001-10-18-05:56:55.228 h110 [8156] lpd  lpd: listening socket fd -6
1829    Fatal error - Another print spooler is using TCP printer
1830        port, possibly lpd process '8154'
1831    2001-10-18-05:56:55.228 h110 [8156] lpd  cleanup: done, exit(1)
1832    h110# killall lpd
1833    h110# lpd -F -D1
1834    2001-10-18-05:57:05 [8158] lpd  Initialize: starting
1835    ...
1836    2001-10-18-05:57:05.800 h110 [8159] Waiting  lpd: LOOP START
1837    2001-10-18-05:57:05.800 h110 [8159] Waiting
1838          lpd: starting select timeout 'yes', 600 sec, max_socks 7
1839    
1840    ---- other window
1841         h110: {5} % lpr /tmp/hi
1842    ----
1843    
1844    2001-10-18-05:57:44.341 h110 [8159] Waiting
1845         lpd: select returned 1, error 'No Error'
1846    2001-10-18-05:57:44.342 h110 [8159] Waiting
1847         lpd: fd 5 readable
1848    2001-10-18-05:57:44.342 h110 [8159] Waiting  lpd: connection fd 8
1849    2001-10-18-05:57:44.351 h110 [8159] Waiting  Start_worker: fd 8
1850    
1851    2001-10-18-05:57:44.356 h110 [8171] RECV  lp: Fix_Rm_Rp_info: printer name 'lp'
1852    2001-10-18-05:57:44.356 h110 [8171] RECV  Reset_config: starting
1853    2001-10-18-05:57:44.361 h110 [8171] RECV
1854         lp: Select_pc_info: looking for 'lp', depth 0
1855    ...
1856</pre>
1857          </div>
1858
1859          <p>This shows <i class="EMPHASIS">all</i> of the
1860          information available about the printing operation. But
1861          it is jumbled all together. Usually you want to see just
1862          the information about a single spool queue.</p>
1863
1864          <div class="FIGURE">
1865            <a name="AEN346"></a>
1866
1867            <p><b>Figure 2-22. Debugging Spool Queue</b></p>
1868<pre class="SCREEN">
1869    Printcap:
1870      lp:sd=/var/spool/lpd/%P
1871        :db=<i class="EMPHASIS">DebugOptions</i>
1872           db=1     - output to device level 1,
1873           db=lpc db=lpq db=lpr db=lprm
1874                    - incoming lpc, lpq, lpr, lprm operations
1875    
1876    Spool Queue:  /var/spool/lpd/lp
1877      Default Files - created by <b class="APPLICATION">checkpc</b>
1878        control.%P  - queue control (enable, disable...)
1879        acct        - accounting
1880        status      - filter status
1881        status.%P   - queue status
1882        log         - diagnostics
1883</pre>
1884          </div>
1885
1886          <p>The <b class="APPLICATION">checkpc</b> program creates
1887          a standard set of files in each spool queue, including
1888          the <tt class="LITERAL">log</tt> file. The <tt class=
1889          "LITERAL">:db=</tt><i class="EMPHASIS">DebugOptions</i>
1890          enables debugging output for the specified operation.
1891          Information is sent to the <tt class="LITERAL">log</tt>
1892          file as soon as the print queue directory and debug flags
1893          for the spool queue are determined.</p>
1894
1895          <div class="FIGURE">
1896            <a name="AEN357"></a>
1897
1898            <p><b>Figure 2-23. Setting Queue Debug Options</b></p>
1899<pre class="SCREEN">
1900    h110# vi /etc/printcap
1901      set:
1902        lp:...
1903          :db=lpr
1904    h110# lpc reread
1905    lpd server pid 8200 on h110.private, sending SIGHUP
1906</pre>
1907          </div>
1908
1909          <p>Edit the printcap. You can then use <tt class=
1910          "LITERAL">lpc reread</tt> to signal the <b class=
1911          "APPLICATION">lpd</b> process to read the new <tt class=
1912          "FILENAME">/etc/printcap</tt> file.</p>
1913
1914          <div class="FIGURE">
1915            <a name="AEN364"></a>
1916
1917            <p><b>Figure 2-24. <tt class="LITERAL">log</tt>
1918            File</b></p>
1919<pre class="SCREEN">
1920    2001-10-18-06:11:30.349 h110 [8216] RECV
1921       lp: Receive_job: debug 'lpr', Debug 0, DbgFlag 0x1000
1922    2001-10-18-06:11:30.349 h110 [8216] RECV
1923       lp: Receive_job: spooling_disabled 0
1924    2001-10-18-06:11:30.349 h110 [8216] RECV
1925       lp: Receive_job: sending 0 ACK for job transfer request
1926    2001-10-18-06:11:30.349 h110 [8216] RECV
1927       lp: Receive_job: from localhost.my.domain- getting file transfer line
1928    2001-10-18-06:11:30.349 h110 [8216] RECV
1929       lp: Receive_job: read from localhost.my.domain-
1930           status 0 read 23 bytes '^B131 cfA215h110.private'
1931</pre>
1932          </div>
1933
1934          <p>You can now use the <tt class="LITERAL">log</tt> file
1935          to see the individual queue operations. The size of the
1936          log file is determined by the <tt class=
1937          "LITERAL">max_log_file_size</tt> (default is 1000Kbytes);
1938          when the log file exceeds this it is truncted to 25% of
1939          its maximum length.</p>
1940        </div>
1941      </div>
1942
1943      <div class="CHAPTER">
1944        <hr>
1945
1946        <h1><a name="AEN371">Chapter 3. Printers</a></h1>
1947
1948        <div class="FIGURE">
1949          <a name="AEN373"></a>
1950
1951          <p><b>Figure 3-1. Printer Types</b></p>
1952<pre class="SCREEN">
1953    Printers:
1954      Cheap and Slow Ink Dispensers
1955      Not So Cheap Fast Printers
1956      Vintage Stuff On Sale
1957      Legacy Junk You Are Stuck With
1958</pre>
1959        </div>
1960
1961        <p>Your office mate has just purchased a nice new $99
1962        ink-jet printer and wants to use it on his office desktop.
1963        Your boss calls you in and tells you that the new <i class=
1964        "EMPHASIS">PlattenPusher 5500</i> printer will arrive and
1965        it needs to be operational ASAP. And finally, you pick up a
1966        really good bargin on a used <i class=
1967        "EMPHASIS">HP4mPlus</i> laser printer, which all the folks
1968        on the <b class="APPLICATION">LPRng</b> mailing list
1969        recommend as the most reliable (and SLOW...) printer they
1970        ever used.</p>
1971
1972        <p>With your luck, probably all three happen on the same
1973        day. Welcome to the wonderful world of printers.</p>
1974
1975        <div class="SECT1">
1976          <hr>
1977
1978          <h1 class="SECT1"><a name="AEN381">3.1.
1979          Interface</a></h1>
1980
1981          <div class="FIGURE">
1982            <a name="AEN383"></a>
1983
1984            <p><b>Figure 3-2. Interface Types</b></p>
1985<pre class="SCREEN">
1986    Connection:
1987      Parallel port : write only (no status)
1988                      read/write (maybe you get status)
1989      Serial port:    read/write (status)
1990      Network:        serial port emulator
1991                      parallel port emulator
1992                      print spooler emulator
1993                      whacko interface
1994</pre>
1995          </div>
1996
1997          <p>The type of interface on your printer is usually a
1998          function of the printer cost and speed. The low cost/low
1999          speed printers usually have a parallel port interface,
2000          while the higher cost/higher speed printers usually have
2001          both a parallel port <i class="EMPHASIS">and</i> a
2002          network interface. Serial ports are usually found only on
2003          older model printers or those which have very special
2004          facilities.</p>
2005        </div>
2006
2007        <div class="SECT1">
2008          <hr>
2009
2010          <h1 class="SECT1"><a name="AEN388">3.2. Parallel
2011          Port</a></h1>
2012
2013          <div class="FIGURE">
2014            <a name="P2"></a>
2015
2016            <p><b>Figure 3-3. Parallel Port</b></p>
2017
2018            <div class="MEDIAOBJECT">
2019              <p><img src="parallel.png"></p>
2020            </div>
2021          </div>
2022
2023          <p>Some printers provide <i class="EMPHASIS">status</i>
2024          information. In order to do this they need a <i class=
2025          "EMPHASIS">bidirectional</i> communications channel. The
2026          parallel port interface found on the original X86
2027          PC/XT/ATX systems was write only. However, there were a
2028          couple of signals (<tt class="LITERAL">OUT OF PAPER</tt>,
2029          <tt class="LITERAL">ERROR</tt>, etc.) that provided
2030          status information to the computer system. By monitoring
2031          these signals the host computer could tell the user that
2032          there were problems with the printer. Fiendishly clever
2033          engineers discovered that they could use these signals to
2034          implement a <i class="EMPHASIS">bidirectional data
2035          channel</i> over the parallel port. They could even put
2036          multiple devices (daisy chained) on the parallel port.
2037          Needless to say, of the hundreds of companies that used
2038          bidirectional parallel interfaces no two of them used the
2039          same method.</p>
2040
2041          <p>In a fit of desperation, the IEEE1284 standard (well,
2042          actually 3 standards) were developed to allow at least
2043          some sort of general consensus on how a bidirectional
2044          parallel port should work.</p>
2045
2046          <p>If you are interested in the details about Parallel
2047          Ports, see <a href="http://www.fapo.com/1284int.htm"
2048          target="_top">http://www.fapo.com/1284int.htm</a> for a
2049          nice introduction, and the IEEE1394 Trade Association
2050          Home Page <a href="http://www.1394ta.org/" target=
2051          "_top">http://www.1394ta.com/</a> for pointers to other
2052          information.</p>
2053
2054          <p>The good news is that if your printer is IEEE1284
2055          compliant, then it has a functional bidirectional
2056          interface that will return status and other information.
2057          The bad news, <i class="EMPHASIS">really</i> bad news,
2058          and <i class="EMPHASIS">really</i> <i class=
2059          "EMPHASIS">really</i> bad news is a) there is no software
2060          level API for using bidirectionality; b) the parallel IO
2061          drivers that exist differ from version to version; c)
2062          most of the time the status returned by the printer is
2063          useless anyways.</p>
2064
2065          <p>Given this set of problems I recommend that you:</p>
2066
2067          <ul>
2068            <li>
2069              <p>Put only one device (your printer) on each
2070              parallel port.</p>
2071            </li>
2072
2073            <li>
2074              <p>Do not expect to get status information back from
2075              the printer.</p>
2076            </li>
2077          </ul>
2078
2079          <div class="FIGURE">
2080            <a name="P1"></a>
2081
2082            <p><b>Figure 3-4. Parallel Port Printcap</b></p>
2083<pre class="SCREEN">
2084    lp:lp=/dev/lpt0
2085      :sd=/var/spool/lpd/%P
2086</pre>
2087          </div>
2088          &#13;<br>
2089          <br>
2090
2091          <p>As shown in <a href="#FG1">Figure 1-1</a>, the
2092          printcap entry for a parallel port (without a filter) is
2093          really simple. If your printer is offline or powered
2094          down, <b class="APPLICATION">lpd</b> will not be able to
2095          open the parallel port and you will see an endless list
2096          of error messages in the status file.</p>
2097
2098          <div class="FIGURE">
2099            <a name="P3"></a>
2100
2101            <p><b>Figure 3-5. Loading Linux Parallel Port
2102            Driver</b></p>
2103<pre class="SCREEN">
2104    [papowell@h112 papowell]$ su
2105    Password:
2106    [root@h112 papowell]# echo &lt;/dev/lp0
2107    [root@h112 papowell]# cd /proc/sys/dev/parport/
2108    [root@h112 parport]# ls default  parport0
2109    [root@h112 parport]# cd parport0
2110    [root@h112 parport0]# ls autoprobe  autoprobe0  autoprobe1  autoprobe2
2111       autoprobe3  base-addr  devices  dma  irq  modes  spintime
2112    [root@h112 parport0]# cat autoprobe
2113    CLASS:PRINTER; MODEL:DESKJET 670C;
2114    MANUFACTURER:HEWLETT-PACKARD;
2115    DESCRIPTION:Hewlett-Packard DeskJet 670C;
2116    COMMAND SET:MLC,PCL,PML;
2117</pre>
2118          </div>
2119
2120          <p>The Linux system uses loadable module drivers for the
2121          parallel ports and newer releases support the IEEE1284 <i
2122          class="EMPHASIS">device probe</i> functions. You can use
2123          the command shown in <a href="#P3">Figure 3-5</a> to load
2124          the modules; the <tt class="LITERAL">echo
2125          &lt;/dev/lp0</tt> command tries to open the device in <tt
2126          class="LITERAL">read</tt> mode, and then exits after
2127          reading nothing... which might suggest that you cannot
2128          get status from the device. If you have the <tt class=
2129          "LITERAL">/proc</tt> system installed, then you can see
2130          what the IEEE1284 probe function returned.</p>
2131
2132          <div class="FIGURE">
2133            <a name="P4"></a>
2134
2135            <p><b>Figure 3-6. Parallel Port Problems</b></p>
2136<pre class="SCREEN">
2137    One Interrupt per Output Character
2138       - One Interrupt per Blocks of Characters (DMA)
2139       - Hope that DMA works
2140    May operate by <i class="EMPHASIS">polling</i>
2141    Don't try to daisy chain devices
2142</pre>
2143          </div>
2144
2145          <p>While you may think that you are getting a high
2146          throughput to the parallel port, in actual fact it may be
2147          very slow. In the worst case you will get a an interrupt
2148          for every character output. Even worse, sometimes the
2149          parallel port driver will <i class="EMPHASIS">spin
2150          block</i> for a small period of time in the hopes that a
2151          character will be accepted by the printer so it can send
2152          another one. Finally, while many users have successfully
2153          daisy chained multiple devices, there is a resounding
2154          silence from them when asked about the success of
2155          simultaneous use of the devices.</p>
2156
2157          <p>To add insult to injury, some systems do not even
2158          support interrupts with their parallel port hardware. To
2159          do IO, they periodically <i class="EMPHASIS">poll</i> the
2160          output device to see if it is ready to accept another
2161          character.</p>
2162        </div>
2163
2164        <div class="SECT1">
2165          <hr>
2166
2167          <h1 class="SECT1"><a name="AEN439">3.3. Network
2168          Ports</a></h1>
2169
2170          <div class="FIGURE">
2171            <a name="N1"></a>
2172
2173            <p><b>Figure 3-7. Network Ports</b></p>
2174
2175            <div class="MEDIAOBJECT">
2176              <p><img src="network.png"></p>
2177            </div>
2178          </div>
2179
2180          <p>Most devices that support a network connection do so
2181          by either providing support for a print spooler interface
2182          (<b class="APPLICATION">lpd</b>) or by emulating a
2183          bidirectional connection to the printing device (<i
2184          class="EMPHASIS">socket</i> or <i class=
2185          "EMPHASIS">appsocket</i>). If your printer provides
2186          status reporting, it is <i class="EMPHASIS">strongly</i>
2187          recommended that you use the socket interface. This will
2188          allow you to monitor conditions reported by the
2189          printer.</p>
2190
2191          <div class="FIGURE">
2192            <a name="N2"></a>
2193
2194            <p><b>Figure 3-8. Network Port Printcap</b></p>
2195<pre class="SCREEN">
2196    lp:lp=10.0.0.14%9100
2197      :sd=/var/spool/lpd/%P
2198    
2199    lp2:lp=raw@10.0.0.14
2200      :sd=/var/spool/lpd/%P
2201      # legacy :rp:rm support
2202      # :rp=raw:rm=10.0.0.14
2203</pre>
2204          </div>
2205
2206          <p>The printcap for a network printer is shown in <a
2207          href="#N2">Figure 3-8</a>. You can use the <tt class=
2208          "LITERAL">:rp:rm</tt> options if you want.</p>
2209
2210          <div class="FIGURE">
2211            <a name="N3"></a>
2212
2213            <p><b>Figure 3-9. Benefits of Network Port
2214            Printcap</b></p>
2215<pre class="SCREEN">
2216    High Speed
2217    Low Error Rate (+ Error Detection)
2218    Long Distances
2219    Very low system overhead
2220</pre>
2221          </div>
2222
2223          <p>Network port printing is effectively the highest
2224          speed. The TCP/IP protocol provides both flow control and
2225          error detection/correction. The printer and host system
2226          can be separated by quite large distances. Finally, the
2227          overhead of the TCP/IP connection is very low in terms of
2228          hardware and software.</p>
2229
2230          <div class="FIGURE">
2231            <a name="N4"></a>
2232
2233            <p><b>Figure 3-10. Network Print Server</b></p>
2234
2235            <div class="MEDIAOBJECT">
2236              <p><img src="printserver.png"></p>
2237            </div>
2238          </div>
2239
2240          <p>If you have legacy systems that have serial or
2241          parallel ports, you can buy a <i class="EMPHASIS">Network
2242          Print Server</i> box. These have a network interface and
2243          one or more parallel or serial port interfaces.</p>
2244
2245          <div class="TABLE">
2246            <a name="NEWPS"></a>
2247
2248            <p><b>Table 3-1. Network Print Server Configuration
2249            Information</b></p>
2250
2251            <table border="1" class="CALSTABLE">
2252              <thead>
2253                <tr>
2254                  <th align="LEFT" valign="TOP">Manufacturer</th>
2255
2256                  <th align="LEFT" valign="TOP">Model</th>
2257
2258                  <th align="LEFT" valign="TOP">RFC1179 Port Name
2259                  (rp=XXX)</th>
2260
2261                  <th align="LEFT" valign="TOP">Send to TCP
2262                  port</th>
2263                </tr>
2264              </thead>
2265
2266              <tbody>
2267                <tr>
2268                  <td align="LEFT" valign="TOP"><a href=
2269                  "http://www.cannon.com/" target="_top">Cannon
2270                  Printer</a></td>
2271
2272                  <td align="LEFT" valign="TOP">Cannon 460 PS, no
2273                  hard drive</td>
2274
2275                  <td align="LEFT" valign="TOP"><tt class=
2276                  "LITERAL">xjdirect</tt></td>
2277
2278                  <td align="LEFT" valign="TOP">- Unknown if
2279                  supported -</td>
2280                </tr>
2281
2282                <tr>
2283                  <td align="LEFT" valign="TOP">&nbsp;</td>
2284
2285                  <td align="LEFT" valign="TOP">Cannon 460 PS hard
2286                  drive</td>
2287
2288                  <td align="LEFT" valign="TOP"><tt class=
2289                  "LITERAL">xjprint</tt> - print immediately,<tt
2290                  class="LITERAL">xjhold</tt> - print later</td>
2291
2292                  <td align="LEFT" valign="TOP">- Unknown if
2293                  supported -</td>
2294                </tr>
2295
2296                <tr>
2297                  <td align="LEFT" valign="TOP"><a href=
2298                  "http://www.digprod.com/" target="_top">Digital
2299                  Products Inc.</a></td>
2300
2301                  <td align="LEFT" valign="TOP">NETPrint Print
2302                  Server</td>
2303
2304                  <td align="LEFT" valign="TOP"><tt class=
2305                  "LITERAL">PORT</tt><tt class="LITERAL">n</tt>,
2306                  where <tt class="LITERAL">n</tt> is port on
2307                  server</td>
2308
2309                  <td align="LEFT" valign="TOP">- Unknown if
2310                  supported -</td>
2311                </tr>
2312
2313                <tr>
2314                  <td align="LEFT" valign="TOP"><a href=
2315                  "http://www.efi.com/" target="_top">Electronics
2316                  For Imaging Inc.</a></td>
2317
2318                  <td align="LEFT" valign="TOP">Fiery RIP i
2319                  series</td>
2320
2321                  <td align="LEFT" valign="TOP"><tt class=
2322                  "LITERAL">normalq</tt> or <tt class=
2323                  "LITERAL">urgentq</tt></td>
2324
2325                  <td align="LEFT" valign="TOP">- Unknown if
2326                  supported -</td>
2327                </tr>
2328
2329                <tr>
2330                  <td align="LEFT" valign="TOP">&nbsp;</td>
2331
2332                  <td align="LEFT" valign="TOP">Fiery RIP XJ
2333                  series</td>
2334
2335                  <td align="LEFT" valign="TOP"><tt class=
2336                  "LITERAL">xjprint</tt></td>
2337
2338                  <td align="LEFT" valign="TOP">- Unknown if
2339                  supported -</td>
2340                </tr>
2341
2342                <tr>
2343                  <td align="LEFT" valign="TOP">&nbsp;</td>
2344
2345                  <td align="LEFT" valign="TOP">Fiery RIP XJ+ and
2346                  SI series</td>
2347
2348                  <td align="LEFT" valign="TOP"><tt class=
2349                  "LITERAL">print_</tt><tt class=
2350                  "LITERAL">Model</tt>, e.g. <tt class=
2351                  "LITERAL">print_DocuColor</tt></td>
2352
2353                  <td align="LEFT" valign="TOP">- Unknown if
2354                  supported -</td>
2355                </tr>
2356
2357                <tr>
2358                  <td align="LEFT" valign="TOP">&nbsp;</td>
2359
2360                  <td align="LEFT" valign="TOP">Fiery models
2361                  ZX2100, ZX3300, X2, X2e</td>
2362
2363                  <td align="LEFT" valign="TOP"><tt class=
2364                  "LITERAL">print</tt></td>
2365
2366                  <td align="LEFT" valign="TOP">- Unknown if
2367                  supported -</td>
2368                </tr>
2369
2370                <tr>
2371                  <td align="LEFT" valign="TOP"><a href=
2372                  "http://www.emulex.com/" target="_top">Emulex
2373                  Corp.</a></td>
2374
2375                  <td align="LEFT" valign="TOP">NETJet/NETQue print
2376                  server</td>
2377
2378                  <td align="LEFT" valign="TOP"><tt class=
2379                  "LITERAL">PASSTHRU</tt></td>
2380
2381                  <td align="LEFT" valign="TOP">- Unknown if
2382                  supported -</td>
2383                </tr>
2384
2385                <tr>
2386                  <td align="LEFT" valign="TOP"><a href=
2387                  "http://www.extendsys.com/" target=
2388                  "_top">Extended Systems Inc.</a></td>
2389
2390                  <td align="LEFT" valign="TOP">ExtendNet Print
2391                  Server</td>
2392
2393                  <td align="LEFT" valign="TOP"><tt class=
2394                  "LITERAL">Printer<tt class=
2395                  "REPLACEABLE"><i>n</i></tt></tt>, where <tt
2396                  class="LITERAL">n</tt> is port on server</td>
2397
2398                  <td align="LEFT" valign="TOP">- Unknown if
2399                  supported -</td>
2400                </tr>
2401
2402                <tr>
2403                  <td align="LEFT" valign="TOP"><a href=
2404                  "http://www.hp.com/" target=
2405                  "_top">Hewlett-Packard</a></td>
2406
2407                  <td align="LEFT" valign="TOP">JetDirect interface
2408                  card</td>
2409
2410                  <td align="LEFT" valign="TOP"><tt class=
2411                  "LITERAL">raw</tt></td>
2412
2413                  <td align="LEFT" valign="TOP">9100</td>
2414                </tr>
2415
2416                <tr>
2417                  <td align="LEFT" valign="TOP"><a href=
2418                  "http://www.hp.com/" target=
2419                  "_top">Hewlett-Packard</a></td>
2420
2421                  <td align="LEFT" valign="TOP">JetDirect Multiport
2422                  Server</td>
2423
2424                  <td align="LEFT" valign="TOP"><tt class=
2425                  "LITERAL">port 1 - raw1, port 2 - raw2,
2426                  etc.</tt></td>
2427
2428                  <td align="LEFT" valign="TOP">port 1 - 9100, port
2429                  2 - 9101, etc.</td>
2430                </tr>
2431
2432                <tr>
2433                  <td align="LEFT" valign="TOP"><a href=
2434                  "http://www.i-data.com/" target=
2435                  "_top">I-Data</a></td>
2436
2437                  <td align="LEFT" valign="TOP">Easycom 10
2438                  Printserver</td>
2439
2440                  <td align="LEFT" valign="TOP"><tt class=
2441                  "LITERAL">par1</tt> (parallel port 1)</td>
2442
2443                  <td align="LEFT" valign="TOP">- Unknown if
2444                  supported -</td>
2445                </tr>
2446
2447                <tr>
2448                  <td align="LEFT" valign="TOP">&nbsp;</td>
2449
2450                  <td align="LEFT" valign="TOP">Easycom 100
2451                  Printserver</td>
2452
2453                  <td align="LEFT" valign="TOP"><tt class=
2454                  "LITERAL">LPDPRT1</tt></td>
2455
2456                  <td align="LEFT" valign="TOP">- Unknown if
2457                  supported -</td>
2458                </tr>
2459
2460                <tr>
2461                  <td align="LEFT" valign="TOP"><a href=
2462                  "http://www.printers.ibm.com/" target=
2463                  "_top">IBM</a></td>
2464
2465                  <td align="LEFT" valign="TOP">Network Printer 12,
2466                  17, 24, and 24PS</td>
2467
2468                  <td align="LEFT" valign="TOP"><tt class=
2469                  "LITERAL">PASS</tt></td>
2470
2471                  <td align="LEFT" valign="TOP">- Unknown if
2472                  supported -</td>
2473                </tr>
2474
2475                <tr>
2476                  <td align="LEFT" valign="TOP"><a href=
2477                  "http://www.lantronix.com/" target=
2478                  "_top">Lantronix</a></td>
2479
2480                  <td align="LEFT" valign="TOP">EPS1, EPS2</td>
2481
2482                  <td align="LEFT" valign="TOP"><tt class=
2483                  "LITERAL">EPS_<tt class="LITERAL">X_S1 (serial)
2484                  port 1, EPS_X</tt>_P1 (parallel) port 2</tt>,
2485                  etc.</td>
2486
2487                  <td align="LEFT" valign="TOP">3001 (port 1), 3002
2488                  (port 2), etc.</td>
2489                </tr>
2490
2491                <tr>
2492                  <td align="LEFT" valign="TOP"><a href=
2493                  "http://www.qms.com/" target="_top">QMS</a></td>
2494
2495                  <td align="LEFT" valign="TOP">Various Models</td>
2496
2497                  <td align="LEFT" valign="TOP"><tt class=
2498                  "LITERAL">RAW</tt></td>
2499
2500                  <td align="LEFT" valign="TOP">35 (AppSocket)</td>
2501                </tr>
2502
2503                <tr>
2504                  <td align="LEFT" valign="TOP"><a href=
2505                  "http://www.tek.com/color_printers/" target=
2506                  "_top">Tektronix</a></td>
2507
2508                  <td align="LEFT" valign="TOP">Tektronix printer
2509                  network cards</td>
2510
2511                  <td align="LEFT" valign="TOP"><tt class=
2512                  "LITERAL">PS</tt> (PostScript), <tt class=
2513                  "LITERAL">PCL</tt> (PCL), or <tt class=
2514                  "LITERAL">AUTO</tt>(Auto-selection between PS,
2515                  PCL, or HPGL). Not reliable.</td>
2516
2517                  <td align="LEFT" valign="TOP">9100 (AppSocket on
2518                  some models)</td>
2519                </tr>
2520
2521                <tr>
2522                  <td align="LEFT" valign="TOP"><a href=
2523                  "http://www.rosel.com" target="_top">Rose
2524                  Electronics</a></td>
2525
2526                  <td align="LEFT" valign="TOP">Microserve Print
2527                  Servers</td>
2528
2529                  <td align="LEFT" valign="TOP">lp</td>
2530
2531                  <td align="LEFT" valign="TOP">9100</td>
2532                </tr>
2533
2534                <tr>
2535                  <td align="LEFT" valign="TOP"><a href=
2536                  "http://www.xerox.com/" target=
2537                  "_top">Xerox</a></td>
2538
2539                  <td align="LEFT" valign="TOP">Models 4505, 4510,
2540                  4517, 4520</td>
2541
2542                  <td align="LEFT" valign="TOP"><tt class=
2543                  "LITERAL">PASSTHRU</tt></td>
2544
2545                  <td align="LEFT" valign="TOP">2501 (AppSocket on
2546                  some models)</td>
2547                </tr>
2548
2549                <tr>
2550                  <td align="LEFT" valign="TOP">&nbsp;</td>
2551
2552                  <td align="LEFT" valign="TOP">Model 4512</td>
2553
2554                  <td align="LEFT" valign="TOP"><tt class=
2555                  "LITERAL">PORT1</tt></td>
2556
2557                  <td align="LEFT" valign="TOP">10001
2558                  (programmable)</td>
2559                </tr>
2560
2561                <tr>
2562                  <td align="LEFT" valign="TOP">&nbsp;</td>
2563
2564                  <td align="LEFT" valign="TOP">Model N17</td>
2565
2566                  <td align="LEFT" valign="TOP"><tt class=
2567                  "LITERAL">RAW</tt></td>
2568
2569                  <td align="LEFT" valign="TOP">9100</td>
2570                </tr>
2571
2572                <tr>
2573                  <td align="LEFT" valign="TOP">&nbsp;</td>
2574
2575                  <td align="LEFT" valign="TOP">Models N24 and
2576                  N32</td>
2577
2578                  <td align="LEFT" valign="TOP"><tt class=
2579                  "LITERAL">RAW</tt></td>
2580
2581                  <td align="LEFT" valign="TOP">2000</td>
2582                </tr>
2583
2584                <tr>
2585                  <td align="LEFT" valign="TOP">&nbsp;</td>
2586
2587                  <td align="LEFT" valign="TOP">Models 4900, 4915,
2588                  4925, C55</td>
2589
2590                  <td align="LEFT" valign="TOP"><tt class=
2591                  "LITERAL">PS</tt></td>
2592
2593                  <td align="LEFT" valign="TOP">2000</td>
2594                </tr>
2595
2596                <tr>
2597                  <td align="LEFT" valign="TOP">&nbsp;</td>
2598
2599                  <td align="LEFT" valign="TOP">Document Centre
2600                  DC220/230</td>
2601
2602                  <td align="LEFT" valign="TOP"><tt class=
2603                  "LITERAL">lp</tt></td>
2604
2605                  <td align="LEFT" valign="TOP">- Unknown if
2606                  supported -</td>
2607                </tr>
2608              </tbody>
2609            </table>
2610          </div>
2611
2612          <p>All company, brand, and product names are properties
2613          of their respective owners.</p>
2614        </div>
2615
2616        <div class="SECT1">
2617          <hr>
2618
2619          <h1 class="SECT1"><a name="AEN647">3.4. Sending To SMB
2620          (Samba, Microsoft) Printer, Novell, Appletalk</a></h1>
2621
2622          <div class="FIGURE">
2623            <a name="AEN649"></a>
2624
2625            <p><b>Figure 3-11. Using Program To Send To
2626            Printer</b></p>
2627
2628            <div class="MEDIAOBJECT">
2629              <p><img src="samba.png"></p>
2630            </div>
2631          </div>
2632
2633          <p>There are a wide number of other print spooling
2634          systems that have been developed over the years. Most of
2635          these use proprietary or arcane protocols to transfer
2636          files. These include the <span class="ACRONYM">SMB</span>
2637          protocol used by Microsoft, the Novell print spooler
2638          support, and the Apple corporation Appletalk (Copyright,
2639          Trademarks where applicable). These systems usually run
2640          on or with non-UNIX Operating Systems or on proprietary
2641          hardware. But over the years packages have been developed
2642          to interface to these systems.</p>
2643
2644          <div class="FIGURE">
2645            <a name="AEN656"></a>
2646
2647            <p><b>Figure 3-12. Protocols, Packages, and Transfer
2648            Programs</b></p>
2649<pre class="SCREEN">
2650    Protocol        Package       Transfer Program
2651    SMB (CIFS)      Samba         smbclient + wrapper
2652       WWW: <a href="http://www.samba.org" target=
2653"_top">http://www.samba.org</a>
2654    Novell Netware  ncpfs (Linux) nprint + wrapper
2655       FTP: <a href="ftp.gwdg.de/pub/linux/misc/ncpfs" target=
2656"_top">ftp.gwdg.de/pub/linux/misc/ncpfs</a>
2657       (Also Linux Kernel Documentation/filesystems)
2658    Appletalk       CAPS          pap + wrapper
2659       WWW: <a href="http://sourceforge.net/projects/netatalk"
2660target="_top">http://sourceforge.net/projects/netatalk</a>
2661       WWW: <a href="http://www.umich.edu/~rsug/netatalk" target=
2662"_top">http://www.umich.edu/~rsug/netatalk</a>
2663</pre>
2664          </div>
2665
2666          <p>Each of these programs will transfer a print job to a
2667          remote system.</p>
2668
2669          <div class="FIGURE">
2670            <a name="AEN664"></a>
2671
2672            <p><b>Figure 3-13. Printcap For Transfer
2673            Programs</b></p>
2674<pre class="SCREEN">
2675    lp:
2676      <i class="EMPHASIS">OR</i>
2677      :lp=|/usr/local/lib/filters/smbprint
2678      <i class="EMPHASIS">OR</i>
2679      :lp=|/usr/local/lib/filters/ncpprint
2680      <i class="EMPHASIS">OR</i>
2681      :lp=|/usr/local/lib/filters/atalkprint
2682      # and the magic happens here
2683      :options=authfile="auth" host="h114" printer="lp" workgroup="ASTART"
2684      # See the LPRng/UTILS directory
2685</pre>
2686          </div>
2687
2688          <p>You can specify a <i class="EMPHASIS">program</i> to
2689          do the transfer to the remote host. The program will
2690          connect to the remote system and transfer <tt class=
2691          "LITERAL">STDIN</tt> to the printer. Errors will be
2692          written to <tt class="LITERAL">STDERR</tt> and be put in
2693          the log by <b class="APPLICATION">LPRng</b>.</p>
2694
2695          <div class="FIGURE">
2696            <a name="WRAPPER"></a>
2697
2698            <p><b>Figure 3-14. Samba smbclient Wrapper</b></p>
2699<pre class="SCREEN">
2700    #!/bin/sh
2701    # configuration
2702    smbclient=/usr/local/bin/smbclient
2703    
2704    # get options from $PRINTCAP_ENTRY environment variable
2705    PATH=/bin:/usr/bin:/usr/local/bin
2706    options=`echo "${PRINTCAP_ENTRY}" | sed -n 's/:options=//p' `
2707    echo OPTIONS $options &gt;&amp;2
2708    if [ -n "$options" ] ; then
2709        # paranoia:  $options=`echo |perl -sp 's/[^\w\s,-+%="\']/ /'`
2710        eval dummy=v `echo $options`;
2711    fi
2712    
2713    if [ "$oldversion" != "" -a "$authfile" != "" -a -f "$authfile" ] ; then
2714        . $authfile;
2715        $authfile=
2716    fi
2717    
2718    if [ "$translate" = "yes" ]; then
2719     command="translate ; print -"
2720    else
2721     command="print -"
2722    fi
2723    
2724    echo $smbclient "$share" ${password:+password} -E \
2725     ${username:+-U} ${username:+username} ${hostip:+-I} \
2726     $hostip -N ${workgroup:+-W} $workgroup \
2727     ${authfile:+-A} $authfile -c "$command" &gt;&amp;2
2728    $smbclient "$share" ${password} -E \
2729     ${username:+-U} ${username} ${hostip:+-I} \
2730     $hostip -N ${workgroup:+-W} $workgroup \
2731     ${authfile:+-A} $authfile -c "$command" &gt;&amp;2
2732</pre>
2733          </div>
2734
2735          <p>The <b class="APPLICATION">smbprint</b> script is run
2736          with the <tt class="LITERAL">$PRINTCAP_ENTRY</tt>
2737          environment variable set to the printcap (See <a href=
2738          "#PC">Figure 3-15</a>). The value is scanned for the <tt
2739          class="LITERAL">:options</tt> line and then this line is
2740          used with <tt class="LITERAL">eval</tt> to set variables.
2741          This is a slight security risk and you should not have
2742          any metacharacters in the options field, so you can
2743          optionally strain them out or you can trust in your
2744          editting skills in the printcap.</p>
2745
2746          <div class="FIGURE">
2747            <a name="PC"></a>
2748
2749            <p><b>Figure 3-15. <tt class=
2750            "LITERAL">$PRINTCAP_ENTRY</tt></b></p>
2751<pre class="SCREEN">
2752    lp:
2753      :lp=|/usr/local/lib/filters/smbprint
2754      :options=authfile="auth" host="h114" printer="lp" workgroup="ASTART"
2755</pre>
2756          </div>
2757
2758          <p>There older versions of the <b class=
2759          "APPLICATION">smbclient</b> required the user name and
2760          password on the command line. Unfortunately, the <tt
2761          class="LITERAL">ps</tt> command would show the command
2762          line options, allowing users to see the password. Newer
2763          versions can read username and password from an
2764          authentication file. We can use either version by setting
2765          the <tt class="LITERAL">oldversion</tt> option.</p>
2766
2767          <p>Finally, we echo the command for logging purposes
2768          (note that <tt class="LITERAL">$password</tt> is <i
2769          class="EMPHASIS">not</i> displayed and then run the <tt
2770          class="LITERAL">smbclient</tt> command.</p>
2771
2772          <div class="FIGURE">
2773            <a name="AEN697"></a>
2774
2775            <p><b>Figure 3-16. Novell and Appletalk
2776            Wrappers</b></p>
2777<pre class="SCREEN">
2778    ncpprint:
2779     ....
2780     usercmd=""
2781     if [ "$username" != "" ]; then
2782       if [ "$password" != "" ]; then
2783         usercmd="-U $username -P $password"
2784       else
2785         usercmd="-U $username -n"
2786       fi
2787     fi
2788     nprint=/usr/bin/nprint -S $server -q $printer \
2789        $usercmd -N - 2&gt;/dev/null
2790    
2791    atalkprint:
2792     ...
2793     /usr/bin/pap -p "$username:$printer@$host"
2794</pre>
2795          </div>
2796
2797          <p>This general template can also be used with the <b
2798          class="APPLICATION">nprint</b> command from the Novell
2799          Netware support package to send files to a Novel Netware
2800          printers and the <b class="APPLICATION">pap</b> command
2801          from the Netatalk package.</p>
2802        </div>
2803
2804        <div class="SECT1">
2805          <hr>
2806
2807          <h1 class="SECT1"><a name="AEN703">3.5. Serial
2808          Port</a></h1>
2809
2810          <div class="FIGURE">
2811            <a name="S1"></a>
2812
2813            <p><b>Figure 3-17. Serial Port</b></p>
2814
2815            <div class="MEDIAOBJECT">
2816              <p><img src="serial.png"></p>
2817            </div>
2818          </div>
2819
2820          <p>A serial line is usually bidirectional in operation,
2821          but there are very few printers that will return status
2822          information. The most notable exception to this are <tt
2823          class="LITERAL">PostScript</tt> printers. If you use a
2824          serial port printer, it is absolutely essential that you
2825          implement <i class="EMPHASIS">flow control</i>, and
2826          almost mandatory that you use <tt class=
2827          "LITERAL">hardware</tt> or <tt class=
2828          "LITERAL">RTS-CTS</tt> (Request To Send and Clear To
2829          Send) flow control. Finally, you need to have the serial
2830          line operate in <tt class="LITERAL">RAW</tt> mode, so
2831          that the serial line driver does not abuse the output
2832          stream by introducing extraneous <tt class=
2833          "LITERAL">CR-LF</tt> sequences, and changing control
2834          characters such as <tt class="LITERAL">ESC</tt> (Escape)
2835          into <tt class="LITERAL">^E</tt> sequences.</p>
2836
2837          <div class="FIGURE">
2838            <a name="S2"></a>
2839
2840            <p><b>Figure 3-18. Serial Port Printcap</b></p>
2841<pre class="SCREEN">
2842    lp:lp=/dev/tty00
2843      :stty=raw crtscts 19200
2844      :sd=/var/spool/lpd/%P
2845      # optional Open Read Write
2846      #:rw
2847</pre>
2848          </div>
2849
2850          <p>The <tt class="LITERAL">:stty=...</tt> option is used
2851          to set line characteristics and takes a subset of the <b
2852          class="APPLICATION">stty</b> application parameters. You
2853          need to set the line speed and mode. If you need to get
2854          status information back from the printer, you should add
2855          the <tt class="LITERAL">:rw</tt> (Open Read-Write)
2856          flag.</p>
2857
2858          <p>As you might suspect, the serial port is limited by
2859          the line speed. In addition, it has a higher rate of
2860          errors than you might expect. Most printers that use a
2861          serial port are for <i class="EMPHASIS">legacy</i>
2862          purposes or have low speed and low data transfer
2863          requirements.</p>
2864        </div>
2865      </div>
2866
2867      <div class="CHAPTER">
2868        <hr>
2869
2870        <h1><a name="AEN728">Chapter 4. Printer Job
2871        Formats</a></h1>
2872
2873        <div class="FIGURE">
2874          <a name="AEN730"></a>
2875
2876          <p><b>Figure 4-1. Page Description Lanaguages</b></p>
2877<pre class="SCREEN">
2878    Printer Input File Formats:
2879    
2880      Postscript (Level 1, 2, 3)
2881      PCL (PCL 5)
2882      Text (Really Legacy PCL)
2883    
2884      PJL
2885        Configuration Specification for Job
2886         - PostScript or PCL or HPGL or ...
2887    
2888      Magic Mystery Proprietary Format
2889</pre>
2890        </div>
2891
2892        <p>Most printers will only print jobs that have a
2893        particular format. These formats are called <i class=
2894        "EMPHASIS">Page Description Languages</i>. The most common
2895        are PostScript, PCL, and HPGL.</p>
2896
2897        <div class="FIGURE">
2898          <a name="AEN735"></a>
2899
2900          <p><b>Figure 4-2. How To Identify Print Formats</b></p>
2901<pre class="SCREEN">
2902    Print Job Job Types
2903       Start of File           File Type
2904    
2905       %!                      PostScript - Level Unknown
2906       %!PS-Adobe-1.0          PostScript - Level 1.0
2907       %!PS-Adobe-2.0          PostScript - Level 2.0
2908       %!PS-Adobe-2.1          PostScript - Level 2.0
2909       %!PS-Adobe-3.0          PostScript - Level 2.0
2910       \033%-12345X@PJL        HP Printer Job Language data
2911       \033E\033               HP PCL printer data
2912       This ...                Text
2913</pre>
2914        </div>
2915
2916        <p>The type of file can be identified by looking at the
2917        content near the start of the file. This is how the <b
2918        class="APPLICATION">file</b> program determines the type of
2919        file <a href="#FG1">Figure 1-1</a>.</p>
2920
2921        <div class="FIGURE">
2922          <a name="FILE"></a>
2923
2924          <p><b>Figure 4-3. Using the file Application</b></p>
2925<pre class="SCREEN">
2926    h110: {1} % file *
2927    Makefile:          ASCII English text
2928    atalkprint:        Bourne shell script text executable
2929    logo.gif:          GIF image data, version 89a, 250 x 91,
2930    one.pcl:           HP PCL printer data
2931    one.ps:            PostScript document text conforming at level 3.0
2932    one.pjl:           HP Printer Job Language data
2933    rewindstdin:       ELF 32-bit LSB executable
2934    testpage-a4.fig:   FIG image text, version 3.1
2935    testpage-a4.ps:    PostScript document text conforming at level 2.0
2936    testpage.fig:      FIG image text, version 3.1
2937</pre>
2938        </div>
2939
2940        <div class="SECT1">
2941          <hr>
2942
2943          <h1 class="SECT1"><a name="AEN745">4.1.
2944          PostScript</a></h1>
2945
2946          <div class="FIGURE">
2947            <a name="AEN747"></a>
2948
2949            <p><b>Figure 4-4. One PostScript Page</b></p>
2950<pre class="SCREEN">
2951    %!PS-Adobe-3.0
2952    %% one page (i.e. - a page with a 1 on it)
2953    %%/Times-Roman
2954    /Courier
2955    findfont 200 scalefont setfont
2956    72 300 moveto
2957    (1) show
2958    showpage
2959    
2960    
2961     -- from PostScript Reference Manual 1986
2962        Adobe (www.adobe.com)
2963</pre>
2964          </div>
2965
2966          <p>This is an example of a PostScript File.</p>
2967
2968          <div class="FIGURE">
2969            <a name="AEN751"></a>
2970
2971            <p><b>Figure 4-5. Generate One Page</b></p>
2972<pre class="SCREEN">
2973    h110: {1} % echo 1 |groff -Tps &gt;/tmp/one.ps
2974    h110: {2} % more /tmp/one.ps
2975    %!PS-Adobe-3.0
2976    %%Creator: groff version 1.16.1
2977    %%CreationDate: Thu Oct 18 12:48:45 2001
2978    %%DocumentNeededResources: font Times-Roman
2979    %%DocumentSuppliedResources: procset grops 1.16 1
2980    %%Pages: 1
2981    %%PageOrder: Ascend
2982    %%Orientation: Portrait
2983    %%EndComments
2984    %%BeginProlog
2985    %%BeginResource: procset grops 1.16 1
2986    /setpacking where{
2987    pop
2988    currentpacking
2989    true setpacking
2990    }if
2991    /grops 120 dict dup begin
2992    /SC 32 def
2993    /A/show load def
2994    /B{0 SC 3 -1 roll widthshow}bind def
2995</pre>
2996          </div>
2997
2998          <p>The quick way to generate a test page is use <b class=
2999          "APPLICATION">groff</b>. The <tt class="LITERAL">groff
3000          -Tps</tt> outputs PostScript.</p>
3001
3002          <div class="FIGURE">
3003            <a name="AEN757"></a>
3004
3005            <p><b>Figure 4-6. PostScript Document Structuring
3006            Conventions</b></p>
3007<pre class="SCREEN">
3008    Specifies how a PostScript print job should be formatted
3009    Divides the job up into a  <i class=
3010"EMPHASIS">prolog</i> and <i class="EMPHASIS">body</i>
3011    The body contains <i class="EMPHASIS">pages</i>
3012       - each page is in an individual section
3013       - each page is <i class="EMPHASIS">independant</i>
3014    
3015    Various Levels - 3.0 with PostScript Level 3, etc.
3016</pre>
3017          </div>
3018
3019          <p>Most document generation systems produce PostScript
3020          that meets the PostScript Document Structuring
3021          Convention. This allows you to <i class=
3022          "EMPHASIS">massage</i> PostScript Documents in several
3023          ways.</p>
3024
3025          <p>&#13;</p>
3026
3027          <div class="FIGURE">
3028            <a name="AEN767"></a>
3029
3030            <p><b>Figure 4-7. Tools for PostScript Document
3031            Manipulation</b></p>
3032<pre class="SCREEN">
3033    GhostScript - format conversion
3034       WWW: <a href="http://www.ghostscript.com" target=
3035"_top">http://www.ghostscript.com</a>
3036    PSUtils  - utilities to massage PostScript by Angus Duggan
3037       FTP: <a href="ftp://ftp.dcs.ed.ac.uk/pub/ajcd/" target=
3038"_top">ftp://ftp.dcs.ed.ac.uk/pub/ajcd/</a>
3039       WWW: <a href="http://www.dcs.ed.ac.uk/home/ajcd/psutils/"
3040target="_top">http://www.dcs.ed.ac.uk/home/ajcd/psutils/</a>
3041    psbook            rearranges pages into signatures
3042    psselect          selects pages and page ranges
3043    pstops            performs general page rearrangement and selection
3044    psnup             put multiple pages per physical sheet of paper
3045    psresize          alter document paper size
3046    epsffit           fits an EPSF file to a given bounding box
3047    getafm     (sh)   outputs PostScript to retrieve AFM file from printer
3048    showchar   (sh)   outputs PostScript to draw a character with metric info
3049    fixdlsrps  (perl) filter to fix DviLaser/PS output so that PSUtils works
3050    fixfmps    (perl) filter to fix framemaker documents so that psselect etc. work
3051    fixmacps   (perl) filter to fix Macintosh documents with saner version of md
3052    fixpsditps (perl) filter to fix Transcript psdit documents to work with PSUtils
3053    fixpspps   (perl) filter to fix PSPrint PostScript so that psselect etc. work
3054    fixscribeps (perl) filter to fix Scribe PostScript so that psselect etc. work
3055    fixtpps    (perl) filter to fix Troff Tpscript documents
3056    fixwfwps   (perl) filter to fix Word for Windows documents for PSUtils
3057    fixwpps    (perl) filter to fix WordPerfect documents for PSUtils
3058    fixwwps    (perl) filter to fix Windows Write documents for PSUtils
3059    extractres (perl) filter to extract resources from PostScript files
3060    includeres (perl) filter to include resources into PostScript files
3061    psmerge    (perl) hack script to merge multiple PostScript files
3062</pre>
3063          </div>
3064          &#13;<br>
3065          <br>
3066
3067          <p>The combination of GhostScript and PSutils by Angus
3068          Duggan are a powerful combination.</p>
3069
3070          <div class="FIGURE">
3071            <a name="AEN774"></a>
3072
3073            <p><b>Figure 4-8. Selection of Pages + 4up
3074            Printing</b></p>
3075<pre class="SCREEN">
3076    h110: {81} % psselect -p20-24 LPRng-HOWTO.ps | psnup -4 &gt;p4up.ps
3077    [20] [21] [22] [23] [24] Wrote 5 pages, 38404 bytes
3078    [1] [2] Wrote 2 pages, 42769 bytes
3079</pre>
3080          </div>
3081
3082          <div class="FIGURE">
3083            <a name="AEN777"></a>
3084
3085            <p><b>Figure 4-9. PostScript Output</b></p>
3086
3087            <div class="MEDIAOBJECT">
3088              <p><img src="x_nup.png"></p>
3089            </div>
3090          </div>
3091
3092          <div class="FIGURE">
3093            <a name="AEN782"></a>
3094
3095            <p><b>Figure 4-10. End Of PostScript Job: ^D
3096            (CTRL-D)</b></p>
3097<pre class="SCREEN">
3098    ^D is recognized as an 'end of job'
3099       - causes reset of PostScript interpreter to defaults
3100    
3101    ^D%!PS-Adobe-3.0
3102    ...
3103    ^D
3104    
3105    The Dreaded ^D at Start of Job - causes problems
3106      Rest of job may be ignored!
3107      Solution: strip off ^D at start
3108        (ifhp = ps_eoj_at_start@)
3109    
3110    The Dreaded ^D at End of Job - causes problems when
3111      you are trying to massage postscript or append jobs
3112      Solution: strip off ^D everywhere
3113        (ifhp = ps_eoj_at_end@)
3114</pre>
3115          </div>
3116
3117          <p>The <tt class="LITERAL">^D</tt> (<tt class=
3118          "LITERAL">CTRL-D</tt>) character is evil - it usually
3119          should not be put into raw files.</p>
3120        </div>
3121
3122        <div class="SECT1">
3123          <hr>
3124
3125          <h1 class="SECT1"><a name="AEN788">4.2. PCL</a></h1>
3126
3127          <div class="FIGURE">
3128            <a name="AEN790"></a>
3129
3130            <p><b>Figure 4-11. One PCL Page</b></p>
3131<pre class="SCREEN">
3132    ^[E^[&amp;u600D^[&amp;l2A^[&amp;l0O^[&amp;l0E^[(0N^[(s1p0s0b4101T
3133      ^[(s24V^[*p655x942Y1^L^[E
3134    
3135    Note: ^[ is ESC or \033
3136          ^[E is 'reset printer configuration'
3137</pre>
3138          </div>
3139
3140          <p>This is an example of a PCL file. Note that the file
3141          starts with <tt class="LITERAL">^[E</tt>, or the reset
3142          configuration string. All PCL jobs should start with this
3143          so that the previous job does not cause a problem.</p>
3144
3145          <div class="FIGURE">
3146            <a name="AEN795"></a>
3147
3148            <p><b>Figure 4-12. Generate One Page</b></p>
3149<pre class="SCREEN">
3150    h110: {1} % echo 1 | groff -Tlj4 &gt;/tmp/one.pcl
3151    h110: {2} % more
3152    ^[E^[&amp;u600D^[&amp;l2A^[&amp;l0O^[&amp;l0E^[(0N^[(s1p0s0b4101T
3153      ^[(s24V^[*p655x942Y1^L^[E
3154</pre>
3155          </div>
3156
3157          <p>The quick way to generate a test page is use <b class=
3158          "APPLICATION">groff</b>. The <tt class="LITERAL">groff
3159          -Tlj4</tt> outputs PCL level 5. Again, watch out for the
3160          evil <tt class="LITERAL">^D</tt> (<tt class=
3161          "LITERAL">CTRL-D</tt>) characters.</p>
3162        </div>
3163
3164        <div class="SECT1">
3165          <hr>
3166
3167          <h1 class="SECT1"><a name="AEN803">4.3. Printer Job
3168          Language (PJL) and PostScript, PCL</a></h1>
3169
3170          <div class="FIGURE">
3171            <a name="AEN805"></a>
3172
3173            <p><b>Figure 4-13. PJL Example</b></p>
3174<pre class="SCREEN">
3175    ^[%-12345X@PJL
3176    @PJL RDYMSG DISPLAY = ":"
3177    @PJL USTATUSOFF
3178    @PJL USTATUS JOB = ON
3179    @PJL USTATUS DEVICE = ON
3180    @PJL USTATUS PAGE = ON
3181    @PJL USTATUS TIMED = 10
3182    @PJL ENTER LANGUAGE = POSTSCRIPT
3183    ^D%!
3184    %!PS-Adobe-3.0
3185    %% one page (i.e. - a page with a 1 on it)
3186    %%/Times-Roman
3187    /Courier
3188    findfont 200 scalefont setfont
3189    72 300 moveto
3190    (1) show
3191    showpage
3192    ^D^[%-12345X@PJL
3193    @PJL RDYMSG DISPLAY = ":"
3194    @PJL EOJ NAME = ":"
3195    @PJL USTATUSOFF
3196    @PJL USTATUS JOB = ON
3197    @PJL USTATUS DEVICE = ON
3198    @PJL USTATUS PAGE = ON
3199    @PJL USTATUS TIMED = 10
3200    @PJL RDYMSG DISPLAY = "Done: :"
3201    ^[%-12345X
3202</pre>
3203          </div>
3204
3205          <p>Printer Job Language is used to set up configuration
3206          and other facilities for a printer. It can establish
3207          defaults for printing and provide direction to the
3208          printer on how to handle job items not specified by the
3209          PostScript or PCL language.</p>
3210
3211          <p>The PJL Reset command <tt class=
3212          "LITERAL">^[%-12345X</tt> performs a Print Job lanaguage
3213          independent reset. This allows PJL to be used with
3214          PostScript or PCL.</p>
3215        </div>
3216
3217        <div class="SECT1">
3218          <hr>
3219
3220          <h1 class="SECT1"><a name="AEN811">4.4. Text
3221          Files</a></h1>
3222
3223          <div class="FIGURE">
3224            <a name="AEN813"></a>
3225
3226            <p><b>Figure 4-14. Text Files and The Jaggies</b></p>
3227<pre class="SCREEN">
3228    Text
3229      - usually ASCII characters
3230    
3231    The Dreaded Jaggies
3232    
3233    File:
3234    
3235       This is what you
3236       see on the printer
3237    
3238    Printer output:
3239    
3240       This is what you
3241                       see on the printer
3242</pre>
3243          </div>
3244
3245          <p>Text is usually just ASCII characters. Unix lines are
3246          terminated with new line (<tt class="LITERAL">NL</tt> or
3247          <tt class="LITERAL">\012</tt>, and when sent to a printer
3248          result in <i class="EMPHASIS">The Jaggies</i>. You need
3249          to have carriage returns (<tt class="LITERAL">CR</tt> or
3250          <tt class="LITERAL">\015</tt> added to the file. You need
3251          to fix this by one of several methods.</p>
3252
3253          <div class="FIGURE">
3254            <a name="AEN822"></a>
3255
3256            <p><b>Figure 4-15. Fixing The Jaggies</b></p>
3257<pre class="SCREEN">
3258    Fixing The Jaggies:
3259     Convert NL to CR/NL
3260       Quick and Dirty
3261         sed -e 's/$/\r/'
3262       OR
3263         lpf (<b class="APPLICATION">LPRng</b> utility)
3264    
3265     Make PCL Printer Interpret CR as CR/LF
3266       ^[E  -&gt;  ^[E&amp;k2G
3267       Remove the PCL Reset and add the &amp;k2G
3268        (CR -&gt; CR/LF command)
3269</pre>
3270          </div>
3271        </div>
3272
3273        <div class="SECT1">
3274          <hr>
3275
3276          <h1 class="SECT1"><a name="AEN826">4.5. Magical Mystery
3277          Proprietary Format</a></h1>
3278
3279          <div class="FIGURE">
3280            <a name="AEN828"></a>
3281
3282            <p><b>Figure 4-16. Magical Mystery Formats</b></p>
3283<pre class="SCREEN">
3284    Magical Mystery Proprietary Format
3285      -  Usually a RASTER format
3286    
3287      -  legacy devices such as Versatek Plotters
3288    
3289      -  new super cheap InkJet Printers
3290         The host system needs to do conversion to raster file
3291      -  Dirty Little Secret - some of these understand PCL Level 5
3292         (monochrome) and are compatible with HP LaserJet 4.
3293</pre>
3294          </div>
3295
3296          <p>You should try and see if your printer understands
3297          PCL. Try using GhostScript with the <tt class=
3298          "LITERAL">hpdj</tt>, <tt class="LITERAL">ljet3</tt> or
3299          <tt class="LITERAL">ljet4</tt>.</p>
3300
3301          <div class="FIGURE">
3302            <a name="AEN835"></a>
3303
3304            <p><b>Figure 4-17. GhostScript To The Rescue</b></p>
3305<pre class="SCREEN">
3306    h110: {64} % gs --help
3307    AFPL Ghostscript 6.50 (2000-12-02)
3308    Copyright (C) 2000 Aladdin Enterprises, Menlo Park, CA.  All rights reserved.
3309    Usage: gs [switches] [file1.ps file2.ps ...]
3310    Most frequently used switches: (you can use # in place of =)
3311     -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
3312     -g&lt;width&gt;x&lt;height&gt;  page size in pixels   | -r&lt;res&gt;  pixels/inch resolution
3313     -sDEVICE=&lt;devname&gt;  select device         | -dBATCH  exit after last file
3314     -sOutputFile=&lt;file&gt; select output file: - for stdout, |command for pipe,
3315                                             embed %d or %ld for page #
3316    Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PDF
3317</pre>
3318          </div>
3319
3320          <p>You can read PostScript level 1, 2, or PDF with this
3321          version of GhostScript.</p>
3322
3323          <div class="FIGURE">
3324            <a name="AEN839"></a>
3325
3326            <p><b>Figure 4-18. GhostScript Devices</b></p>
3327<pre class="SCREEN">
3328    Available devices:
3329       x11 bbox x11alpha x11cmyk x11cmyk2 x11cmyk4 x11cmyk8 x11gray2 x11gray4
3330       x11mono x11rg16x x11rg32x atx23 atx24 atx38 deskjet djet500 fs600
3331       laserjet ljetplus ljet2p ljet3 ljet3d ljet4 ljet4d lp2563 oce9050 lj5mono
3332       lj5gray epswrite pswrite pdfwrite pxlmono pxlcolor bit bitrgb bitcmyk
3333       bmpmono bmpgray bmpsep1 bmpsep8 bmp16 bmp256 bmp16m bmp32b cgmmono cgm8
3334       cgm24 jpeg jpeggray miff24 pcxmono pcxgray pcx16 pcx256 pcx24b pcxcmyk
3335       pcx2up pbm pbmraw pgm pgmraw pgnm pgnmraw ppm ppmraw pnm pnmraw pkm
3336       pkmraw pksm pksmraw plan9bm pngmono pnggray png16 png256 png16m psmono
3337       psgray psrgb faxg3 faxg32d faxg4 tiffcrle tiffg3 tiffg32d tiffg4 tifflzw
3338       tiffpack tiff12nc tiff24nc appledmp iwhi iwlo iwlq bj10e bj200 ccr
3339       cdeskjet cdjcolor cdjmono cdj500 cdj550 declj250 dnj650c lj4dith pj pjxl
3340       pjxl300 bjc600 bjc800 escp djet500c cljet5 cljet5pr cljet5c lj3100sw
3341       coslw2p coslwxl cp50 epson eps9mid eps9high ibmpro epsonc ap3250 st800
3342       stcolor uniprint lj250 paintjet pjetxl hl7x0 imagen jetp3852 lbp8 lips3
3343       lp8000 m8510 necp6 lq850 lxm5700m oki182 okiibm photoex sj48 t4693d2
3344       t4693d4 t4693d8 tek4696 cfax dfaxlow dfaxhigh cif inferno mgrmono
3345       mgrgray2 mgrgray4 mgrgray8 mgr4 mgr8 sgirgb sunhmono cdj850 hpdj pcl3
3346       hpdjplus hpdjportable hpdj310 hpdj320 hpdj340 hpdj400 hpdj500 hpdj500c
3347       hpdj510 hpdj520 hpdj540 hpdj550c hpdj560c hpdj600 hpdj660c hpdj670c
3348       hpdj680c hpdj690c hpdj850c hpdj855c hpdj870c hpdj890c hpdj1120c cdj970
3349       stp nullpage
3350</pre>
3351          </div>
3352
3353          <p>GhostScript converts PostScript to a wide range of
3354          output device formats. The interesting ones are <tt
3355          class="LITERAL">ljet4</tt>, <tt class=
3356          "LITERAL">lj5mono</tt>, <tt class="LITERAL">hpdj</tt>,
3357          and so forth. These are Ink Jet printers with various
3358          strange behaviors.</p>
3359
3360          <div class="FIGURE">
3361            <a name="AEN846"></a>
3362
3363            <p><b>Figure 4-19. GhostScript Support</b></p>
3364<pre class="SCREEN">
3365    <a href="http://www.ghostscript.com" target=
3366"_top">http://www.ghostscript.com</a>
3367    <a href="http://www.cs.wisc.edu/~ghost" target=
3368"_top">http://www.cs.wisc.edu/~ghost</a>
3369    <a href="http://www.cs.wisc.edu/~ghost/doc/printer.htm" target=
3370"_top">http://www.cs.wisc.edu/~ghost/doc/printer.htm</a>
3371    <a href="http://www.cs.wisc.edu/~ghost/doc/AFPL/devices.htm"
3372target=
3373"_top">http://www.cs.wisc.edu/~ghost/doc/AFPL/devices.htm</a>
3374</pre>
3375          </div>
3376
3377          <p>The <a href="http://www.ghostscript.com" target=
3378          "_top">http://www.ghostscript.com</a> site has links to
3379          just about everything concerned with GhostScript. the <a
3380          href="http://www.cs.wisc.edu/~ghost" target=
3381          "_top">http://www.cs.wisc.edu/~ghost</a> site mirrors
3382          much of this information. The <a href=
3383          "http://www.cs.wisc.edu/~ghost/doc/printer.htm" target=
3384          "_top">printer.htm</a> and <a href=
3385          "http://www.cs.wisc.edu/~ghost/doc/AFPL/devices.htm"
3386          target="_top">devices.htm</a> are good sources for
3387          information about printing.</p>
3388        </div>
3389
3390        <div class="SECT1">
3391          <hr>
3392
3393          <h1 class="SECT1"><a name="AEN859">4.6. Printing Test
3394          Pages</a></h1>
3395
3396          <div class="FIGURE">
3397            <a name="AEN861"></a>
3398
3399            <p><b>Figure 4-20. Printing Test Pages To Parallel
3400            Port</b></p>
3401<pre class="SCREEN">
3402    #!/bin/sh
3403    for i in one.pcl one.pjl one.ps ; do
3404     cat $i &gt;/dev/lp0
3405    done
3406</pre>
3407          </div>
3408
3409          <p>The easiest way to print the test pages is to try them
3410          all. This is brutal, but you may need to do it at least
3411          once.</p>
3412
3413          <div class="FIGURE">
3414            <a name="AEN865"></a>
3415
3416            <p><b>Figure 4-21. Using Netcat (nc)</b></p>
3417<pre class="SCREEN">
3418    nc -  Netcat by Mudge
3419    <a href="http://www.avian.org/" target=
3420"_top">http://www.avian.org/</a>
3421    <a href="ftp://ftp.lprng.com/pub/LPRng/TOOLS/netcat" target=
3422"_top">ftp://ftp.lprng.com/pub/LPRng/TOOLS/netcat</a>
3423    #!/bin/sh
3424    for i in one.pcl one.pjl one.ps ; do
3425     nc -w10 10.0.0.14 9100  &lt;$i
3426    done
3427    
3428    h110: {453} % sh -x /tmp/testnc
3429    + nc -w10 -v -v 10.0.0.14 9100
3430    h14.private [10.0.0.14] 9100 (jetdirect) open
3431    @PJL USTATUS DEVICE
3432    CODE=10003
3433    DISPLAY="02 WARMING UP"
3434    ONLINE=TRUE
3435    
3436    ...
3437    @PJL USTATUS TIMED
3438    CODE=10001
3439    DISPLAY="Done: papowell /"
3440    ONLINE=TRUE
3441    
3442    ^C
3443</pre>
3444          </div>
3445
3446          <p>Netcat is a handy tool for testing network connections
3447          to a printer. You can also use it as a port mapper and
3448          find out what interesting ports are open on your print
3449          spooler box.</p>
3450        </div>
3451      </div>
3452
3453      <div class="CHAPTER">
3454        <hr>
3455
3456        <h1><a name="AEN872">Chapter 5. Filters</a></h1>
3457
3458        <div class="FIGURE">
3459          <a name="AEN874"></a>
3460
3461          <p><b>Figure 5-1. Filters</b></p>
3462
3463          <div class="MEDIAOBJECT">
3464            <p><img src="filter.png"></p>
3465          </div>
3466        </div>
3467
3468        <p>A filter is responsible for converting the job data
3469        files to a format compatible with the printer, transfering
3470        the job to the printer, and monitoring for any
3471        problems.</p>
3472
3473        <div class="FIGURE">
3474          <a name="AEN880"></a>
3475
3476          <p><b>Figure 5-2. Filter Specification in Printcap
3477          Entry</b></p>
3478<pre class="SCREEN">
3479    # <b class="APPLICATION">LPRng</b>
3480    lp:
3481      :filter=/.../filter
3482    
3483    # Legacy BSD (<b class=
3484"APPLICATION">LPRng</b> is backwards compatible)
3485    lp:
3486      # file 'format' is lower case letter X, filter is
3487      # 'Xf' option value, default format is 'f' so default
3488      # filter is 'if'
3489      :if=/.../filter
3490      :hf=/.../filter
3491</pre>
3492        </div>
3493
3494        <p>The legacy BSD printing system required you to specify a
3495        filter for all input types. LPRng uses <tt class=
3496        "LITERAL">:filter</tt> to specify a default filter. Much
3497        more in line with modern printing.</p>
3498
3499        <div class="FIGURE">
3500          <a name="AEN887"></a>
3501
3502          <p><b>Figure 5-3. Specifying Job Datafile Format</b></p>
3503<pre class="SCREEN">
3504    <b class="APPLICATION">LPRng</b> 'format' selection:
3505    
3506       h110: {295} % lpr -Fx /tmp/hi
3507    
3508    Legacy BSD 'format' selection:
3509    
3510    h110: {295} % lpr -x /tmp/hi
3511    
3512    Format 'b' (Binary) or 'l' (Literal)
3513     for 'Passthrough' Operation - format 'l' is used
3514    
3515    h110: {295} % lpr -l /tmp/hi
3516    h110: {295} % lpr -b /tmp/hi
3517    
3518    Control file example:
3519        Hh110.private
3520        J/tmp/hi
3521        Lpapowell
3522        N/tmp/hi
3523        fdfA383h110.private  &lt;- first letter is format
3524        UdfA383h110.private
3525   
3526</pre>
3527        </div>
3528
3529        <p>The <b class="APPLICATION">lpr</b> <tt class=
3530        "LITERAL">-Fx</tt> (<i class="EMPHASIS">Filter</i> <tt
3531        class="LITERAL">x</tt>) option allows you to specify the
3532        filter type. Which, of course, if you use the <tt class=
3533        "LITERAL">:filter</tt> option is ignored. The Binary or
3534        Literal (<tt class="LITERAL">-b</tt> or <tt class=
3535        "LITERAL">-l</tt> requests <i class="EMPHASIS">Pass
3536        Through</i> treatment from the filter. The filter is still
3537        used, but it is passed a special flag.</p>
3538
3539        <p>In the control file, lines starting with lower case
3540        letters specify a format and the data file to print with
3541        the format.</p>
3542
3543        <div class="FIGURE">
3544          <a name="AEN901"></a>
3545
3546          <p><b>Figure 5-4. Filter Execution Environment</b></p>
3547<pre class="SCREEN">
3548    lp:sd=/var/spool/lpd/%P
3549      :filter=/filter
3550      :lp=/dev/lp
3551    
3552    Execution:
3553      CWD is spool directory (/var/spool/lpd/lp)
3554    
3555    Environment:
3556      PATH=...               - from <tt class=
3557"FILENAME">/etc/lpd.conf</tt>
3558      LD_LIBRARY_PATH=...    - from <tt class=
3559"FILENAME">/etc/lpd.conf</tt>
3560      PRINTER=lp
3561      PRINTCAP_ENTRY=lp:        - printcap entry
3562        :sd=/var/spool/lpd/lp     with %P fixed up
3563        :filter=/filter
3564        :lp=/dev/lp
3565      CONTROL=Aroot@h110+383    - job control file
3566        CA
3567        D2001-10-19-06:40:59.968
3568        Hh110.private
3569        J/tmp/hi
3570        Lroot
3571        Proot
3572        Qlp
3573        N/tmp/hi
3574        fdfA383h110.private
3575        UdfA383h110.private
3576</pre>
3577        </div>
3578
3579        <p>The <tt class="LITERAL">PRINTCAP_PATH</tt> environment
3580        variable has new lines before every colon (<tt class=
3581        "LITERAL">:</tt>) so you can split it up easily in the
3582        filter. See <a href="#WRAPPER">Figure 3-14</a> for an
3583        example of this use. The <tt class="LITERAL">CONTROL</tt>
3584        value is the job control file. The control file contains
3585        the job print request sent to <b class=
3586        "APPLICATION">lpd</b>. The output device is opened <tt
3587        class="LITERAL">Read-Write</tt> if the <tt class=
3588        "LITERAL">:rw</tt> flag is set and it is a real device.
3589        Also, if the output is a filter or network connection then
3590        then the output is <tt class="LITERAL">Read-Write</tt>.</p>
3591
3592        <div class="FIGURE">
3593          <a name="AEN915"></a>
3594
3595          <p><b>Figure 5-5. Command Line Options</b></p>
3596<pre class="SCREEN">
3597    lp:sd=/var/spool/lpd/%P
3598      :filter=/filter
3599      :lp=/dev/lp
3600    
3601    /filter &lt;dfA383h110.private &gt;/dev/lp
3602         <i class=
3603"EMPHASIS">STDIN, STDOUT, STDERR to Filter_status</i>
3604    
3605    -CA -D2001-10-19-06:40:59.968 -Hh110.private -J/tmp/hi -Lroot -Qlp
3606         <i class="EMPHASIS">From the control file</i>
3607    
3608    -Plp -Ff
3609     <i class=
3610"EMPHASIS">Legacy and LPRng, -P printer, -F format</i>
3611    
3612    -n root -h h110.private -f dfA383h110.private
3613       ...
3614     <i class=
3615"EMPHASIS">there are more lower case options than you want to think about</i>
3616   
3617</pre>
3618        </div>
3619
3620        <p>The filter command line options are really agressive due
3621        to history and feeping creaturism. All of the lines in the
3622        control file with a capital letter are passed as shown, the
3623        <tt class="LITERAL">-F</tt> is used for the print job
3624        format, and the <tt class="LITERAL">-c</tt> is set if the
3625        job format was <tt class="LITERAL">l</tt> (Binary or
3626        Literal). The <tt class="LITERAL">-f</tt> also is the name
3627        of the data file. <tt class="LITERAL">STDIN</tt> is set to
3628        the data file and <tt class="LITERAL">STDOUT</tt> to the
3629        output device or network connection. Just to make life
3630        interesting, the name of the accounting file (if it is
3631        specified in the printcap or if it has a default value) is
3632        passed as the last parameter.</p>
3633
3634        <div class="FIGURE">
3635          <a name="AEN929"></a>
3636
3637          <p><b>Figure 5-6. Filter Exit Codes</b></p>
3638<pre class="SCREEN">
3639    Exit Code                Action
3640    0 (JSUCC)                Successful, send filter output to printer
3641    1 (JFAIL)                Failed, retry later
3642    2 (JABORT)               Failed, do not retry, and Abort printing
3643    3 (JREMOVE)              Remove job
3644    4 (JHOLD)                Set job HOLD flag
3645</pre>
3646        </div>
3647
3648        <p>The filter program exit codes can be used to control how
3649        the job is processed. The <tt class="LITERAL">JSUCC</tt>
3650        (0) value is the normal successful exit code. The <tt
3651        class="LITERAL">JFAIL</tt> (1) value is used to indicate
3652        some sort of temporary failure and the job should be
3653        retried again. The <tt class="LITERAL">JABORT</tt> (2) is
3654        more serious, and indicates some system error. The job
3655        should not be retried and printing should stop. The <tt
3656        class="LITERAL">JREMOVE</tt> (3) code simply removes the
3657        job. This is useful if the job is unprintable. Finally, the
3658        <tt class="LITERAL">JHOLD</tt> sets the job <tt class=
3659        "LITERAL">HOLD</tt> flag. The job will not be released for
3660        printing until the <b class="APPLICATION">lpc</b> <tt
3661        class="LITERAL">release</tt> command releases it.</p>
3662
3663        <div class="FIGURE">
3664          <a name="AEN941"></a>
3665
3666          <p><b>Figure 5-7. Solid As A Rock Filter
3667          Operation</b></p>
3668<pre class="SCREEN">
3669    Filter:
3670      - examines input format using <b class="APPLICATION">file</b>
3671      - decides if file format is compatible with printer
3672          if not, can run a conversion program to convert
3673          the output.
3674      - initializes printer by sending magic cookies to it
3675          magic cookies depend on particular device, model, etc.
3676      - transfers output to printer, optionally inserting various
3677          control codes, CR -&gt; CR/LF
3678      - if printer can reports status, then gets status as it does
3679          the transfer operation.
3680      - after transferring job,  sends more magic cookies to tell
3681          printer that job is over
3682      - monitors printer for error status
3683      - exits with an appropriate error code telling exactly what
3684         problems (if any) were encountered.
3685</pre>
3686        </div>
3687
3688        <p>This is what a real filter should do. Note that it
3689        appears to be obvious that you would need to do all
3690        this.</p>
3691
3692        <div class="FIGURE">
3693          <a name="AEN946"></a>
3694
3695          <p><b>Figure 5-8. Solid As A Used Paper Coffee Filter
3696          Operation</b></p>
3697<pre class="SCREEN">
3698    Filter:
3699     - Tosses job at GhostScript for conversion, sets
3700          GhostScript output to STDOUT
3701     - Returns GhostScript exit status
3702</pre>
3703        </div>
3704
3705        <p>OK, I am being a bit harsh. But this is not too far from
3706        the truth. Most filter packages are somewhere between the
3707        two extremes.</p>
3708
3709        <div class="SECT1">
3710          <hr>
3711
3712          <h1 class="SECT1"><a name="AEN951">5.1. Writing Your Own
3713          Filter</a></h1>
3714
3715          <p>If you want to write your own filter you can start
3716          with the following simple examples. In practice you have
3717          two choices: <b class="APPLICATION">Perl</b> or <b class=
3718          "APPLICATION">sh</b>. The first in a filter is to get the
3719          various environment and option values. We will write a
3720          simple filter that converts PostScript files into 4 up
3721          PostScript files.</p>
3722
3723          <p>&#13;</p>
3724
3725          <div class="FIGURE">
3726            <a name="FILTERTEMPLATE"></a>
3727
3728            <p><b>Figure 5-9. Filter Template in perl</b></p>
3729<pre class="SCREEN">
3730    #!/usr/bin/perl
3731    use Getopt::Std;
3732    my $debug = 0;    # always... sigh...
3733    my(%opt, @pc, %options);
3734    
3735    # get command line options
3736    getopts( 'A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:T:S:U:V:W:X:Y:Z:'
3737    . 'a:b:cd:e:f:g:h:i:j:k:l:m:n:o:p:q:r:t:s:u:v:w:x:y:z:', \%opt );
3738    while( @ARGV ){ $opt{acct} = pop @ARGV ; };
3739    
3740    # split up the PRINTCAP_ENTRY environment variable value
3741    @pc = split /\n\s*:/s, ($ENV{PRINTCAP_ENTRY} || "");
3742    shift @pc;  # throw way first entry field, printer name
3743    # set the options
3744    foreach (@pc){ # set the options values
3745        if( /^(.+)=(.*)/ ){ $options{$1} = $2;
3746        } elsif ( /^(.+)@/ ){ $options{$1} = 0;
3747        } else { $options{$_} = 1; }
3748    }
3749    
3750    if( $debug ){ # for those interested
3751        my $s = "";
3752        foreach my $v (sort keys %options ){ $s .= "$v='$options{$v}',"; }
3753        print STDERR "Printcap: '$s'\n"; $s="";
3754        foreach my $v (sort keys %opt){ $s .= "$v='$opt{$v}',"; }
3755        print STDERR "Args: '$s'\n";
3756    }
3757</pre>
3758          </div>
3759          &#13;<br>
3760          <br>
3761
3762          <p>This example shows how to get the various environment
3763          variables and command line options and put them into
3764          handy <i class="EMPHASIS">hashes</i> for easy access. You
3765          should note the special treatment of the <tt class=
3766          "LITERAL">-c</tt> option and the arguments at the end of
3767          the command line. The last argument is the name of the
3768          accounting file (if any).</p>
3769
3770          <div class="FIGURE">
3771            <a name="AEN964"></a>
3772
3773            <p><b>Figure 5-10. How To Determine The Type of Job
3774            File</b></p>
3775<pre class="SCREEN">
3776    my $file = `/usr/bin/file -`; # we find the file type
3777    chomp $file;
3778    print STDERR "File: '$file'\n" if $debug; # show the file type
3779    sysseek STDIN,0,0 or die "cannot seek STDIN - $!";      # rewind to start of file
3780    my $is_postscript = ($file =~ /PostScript/i);
3781    print STDERR "Postscript: '$is_postscript'\n" if $debug; # show the file type
3782    if( $is_postscript ){
3783        my $status = system "/usr/local/bin/psnup", "-4";
3784        if( $status ){
3785            print STDERR "psnup failed - $!\n";
3786            exit 1;
3787        }
3788        exit 0;
3789    }
3790    while( &lt;STDIN&gt; ){ print };
3791    exit 0;
3792</pre>
3793          </div>
3794
3795          <p>To determine the file type we use the <b class=
3796          "APPLICATION">file</b> application. This reads the first
3797          part of the input file and then writes out the determined
3798          file type on its <tt class="LITERAL">STDOUT</tt>. We
3799          check to see if the file is a PostScript file and then
3800          run the <tt class="LITERAL">psnup</tt> command. If it is
3801          not, then we simply write copy <tt class=
3802          "LITERAL">STDIN</tt> to <tt class=
3803          "LITERAL">STDOUT</tt>.</p>
3804
3805          <div class="FIGURE">
3806            <a name="FPC"></a>
3807
3808            <p><b>Figure 5-11. Printcap for Filter</b></p>
3809<pre class="SCREEN">
3810    nup:force_localhost
3811      :filter=/usr/local/libexec/filters/nup
3812      :sd=/var/spool/lpd/%P
3813      :lp=lp@localhost
3814    
3815    (Don't forget to run checkpc!)
3816</pre>
3817          </div>
3818
3819          <p>We set make a printcap entry. Note the use of <tt
3820          class="LITERAL">force_localhost</tt> to make sure that
3821          the print jobs are sent to the right print queue! The
3822          filter output will then be sent to <tt class=
3823          "LITERAL">lp@localhost</tt> for final printing.</p>
3824
3825          <div class="FIGURE">
3826            <a name="FDB"></a>
3827
3828            <p><b>Figure 5-12. Using Filter With $debug=1</b></p>
3829<pre class="SCREEN">
3830     Status: processing 'dfA946h110.private', size 145, format 'f',
3831          IF filter 'nup' at 07:27:30.938
3832     Status: IF filter 'nup' filter msg - 'Printcap: 'cm='Class Test Printer 1',....
3833     Status: IF filter 'nup' filter msg - 'Args: 'A='papowell@h110+946',C='A',....
3834     Status: IF filter 'nup' filter msg - 'File: 'standard input: PostScript document'
3835          at 07:27:30.938
3836     Status: IF filter 'nup' filter msg - 'Postscript: '1'' at 07:27:30.938
3837     Status: IF filter 'nup' filter msg - 'Wrote 0 pages, 1775 bytes' at 07:27:30.940
3838     Status: IF filter 'nup' filter finished at 07:27:30.941
3839     Status: sending job 'papowell@h110+946' to lp@localhost at 07:27:30.943
3840</pre>
3841          </div>
3842
3843          <p><a href="#FDB">Figure 5-12</a> shows the status output
3844          when we set the <tt class="LITERAL">$debug=1</tt>. This
3845          is recommended when you are testing your filters.</p>
3846
3847          <div class="FIGURE">
3848            <a name="FNODB"></a>
3849
3850            <p><b>Figure 5-13. Using Filter With $debug=0</b></p>
3851<pre class="SCREEN">
3852     Status: processing 'dfA021h110.private', size 145, format 'f',
3853       IF filter 'nup' at 07:38:22.416
3854     Status: IF filter 'nup' filter msg - 'Wrote 0 pages, 1775 bytes'
3855       at 07:38:22.472
3856     Status: IF filter 'nup' filter finished at 07:38:22.473
3857     Status: sending job 'papowell@h110+21' to t6@localhost at 07:38:22.475
3858</pre>
3859          </div>
3860
3861          <p><a href="#FNODB">Figure 5-13</a> shows the status
3862          output when we set the <tt class="LITERAL">$debug=0</tt>.
3863          As you can see, it is less chatty and just as informative
3864          to most users.</p>
3865        </div>
3866
3867        <div class="SECT1">
3868          <hr>
3869
3870          <h1 class="SECT1"><a name="AEN991">5.2. The <b class=
3871          "APPLICATION">LPRng</b> IFHP Filter</a></h1>
3872
3873          <div class="FIGURE">
3874            <a name="AEN994"></a>
3875
3876            <p><b>Figure 5-14. ifhp</b></p>
3877<pre class="SCREEN">
3878    <b class="APPLICATION">ifhp</b>   (IFHP)
3879      part of the <b class="APPLICATION">LPRng</b> suite
3880      separate from <b class="APPLICATION">LPRng</b>
3881      not quite as strong as a brick,
3882        but better than a wet paper coffee filter.
3883    
3884      ifhp.conf contains printer configuration information
3885</pre>
3886          </div>
3887
3888          <p>The <b class="APPLICATION">ifhp</b> filter is part of
3889          the LPRng family of programs. It is distributed
3890          separately because the release and update times did not
3891          orginally match. The <b class="APPLICATION">ifhp</b>
3892          filter is intended for use with the <b class=
3893          "APPLICATION">LPRng</b> software and undergoes much of
3894          the same testing.</p>
3895
3896          <p>&#13;</p>
3897
3898          <div class="FIGURE">
3899            <a name="AEN1006"></a>
3900
3901            <p><b>Figure 5-15. ifhp.conf Configuration
3902            Information</b></p>
3903<pre class="SCREEN">
3904    ###   Supported Printers
3905    
3906    ### default - HP 4M Plus, PostScript, PJL, PCL, status, pagecount support
3907    ### apple - PostScript printer, text to PS conversion, status, pagecount support
3908    ### postscript - PostScript printer, text to PS conversion, status, pagecount support
3909    ### ps - PostScript printer, text to PS conversion, status, pagecount support
3910    ### pcl - PCL only printer, no status
3911    ### pcl_gs - HP Laserjet 4 PCL only printer, write only, no status
3912    ### hpiiisi - HP LaserJet III (PCL and PostScript Interpreter)
3913</pre>
3914          </div>
3915          &#13;<br>
3916          <br>
3917
3918          <p>Each printer type has an entry in the <tt class=
3919          "LITERAL">ifhp.conf</tt> configuration file. For
3920          convenience these are put at the start of the file.</p>
3921
3922          <div class="FIGURE">
3923            <a name="AEN1011"></a>
3924
3925            <p><b>Figure 5-16. Default Printer Magic
3926            Cookies</b></p>
3927<pre class="SCREEN">
3928    # magic cookie definitions
3929    [default]
3930    # printer capabilities
3931    pjl    # can do PJL
3932    pcl    # can do PCL 5
3933    ps     # can do PS
3934    text   # can do TEXT
3935    
3936    status  # returns status by default
3937    sync    # needs sync magic cookie sent
3938    ps_sync=
3939      serverdict begin 0 exitserver
3940      statusdict begin false setenginesync end
3941            # PostScript sync magic cookie definition
3942    
3943    # definition of available user options
3944    pjl_user_opts=[ ... simplex duplex ... ]
3945    
3946    # magic cookie strings for use when PJL, PostScript or PCL file
3947    pjl_duplex=@PJL SET DUPLEX = ON
3948    ps_duplex=   statusdict begin true setduplexmode false settumble end
3949    pcl_duplex=\033&amp;l1S
3950</pre>
3951          </div>
3952
3953          <p>Each printer has a configuration section where the
3954          printer capabilities are defined, the user options that
3955          are available are specified, and the magic cookies that
3956          need to be sent to the printer to have the operations
3957          happen are defined. The <tt class="LITERAL">default</tt>
3958          entry species the set of defaults for all the
3959          printers.</p>
3960
3961          <div class="FIGURE">
3962            <a name="AEN1016"></a>
3963
3964            <p><b>Figure 5-17. PostScript Only Printer</b></p>
3965<pre class="SCREEN">
3966    a2ps_converter= /usr/local/bin/a2ps \%s{a2ps_options}
3967    a2ps_options= -q -B -1 -M \%M{papersize} --borders=no -o-
3968    gzip_decompress = /usr/bin/gzip -c -d
3969    
3970    # model for 'apple', 'postscript' or 'ps'
3971    [ apple postscript ps ]
3972    pjl@
3973    pcl@
3974    ps
3975    text@
3976    file_output_match = [
3977      *postscript*       ps
3978      *text*             ps  \%s{a2ps_converter}
3979      *pdf*              ps  \%s{pdf2ps_converter}
3980      *gzip_compressed*  filter  \%s{gzip_decompress}
3981      ]
3982    
3983    # do {
3984    #   $file = (lc ` file - `) =~ s/[\s\n]/_/gs;
3985    #   foreach $line (@file_output_match) {
3986    #     last if globmatch( $file, $line-&gt;[0] );
3987    #   }
3988    #   if( $line-&gt;[2] ){
3989    #      run $file-&gt;[2] and convert input file to format
3990    #   }
3991    # } while $line and $line-&gt;[1] != "filter"
3992    # outfile file format is $line-&gt;[1]
3993</pre>
3994          </div>
3995
3996          <p>Here is an example of a PostScript only printer. The
3997          <tt class="LITERAL">pjl@</tt> <tt class=
3998          "LITERAL">pcl@</tt> and <tt class="LITERAL">text@</tt>
3999          entries turn off PJL, PCL, and TEXT for the printer.</p>
4000
4001          <p>The <tt class="LITERAL">file_output_match</tt> entry
4002          is used to implement a simple conversion facility that
4003          will try to find a conversion from one file type to
4004          another. It is deliberately simple minded, on the grounds
4005          that if you have a special type that you need to do
4006          conversions for all the time then you better make sure
4007          you do it right.</p>
4008
4009          <p>&#13;</p>
4010
4011          <div class="FIGURE">
4012            <a name="AEN1026"></a>
4013
4014            <p><b>Figure 5-18. Using the ifhp Filter</b></p>
4015<pre class="SCREEN">
4016    Printcap:
4017    
4018    lp:sd=/var/spool/lpd/%P
4019      :filter=/usr/local/lib/filters/ifhp
4020      :lp=/dev/lp
4021      # a PostScript printer that does not return status
4022      :ifhp= model=ps,status@
4023</pre>
4024          </div>
4025          &#13;<br>
4026          <br>
4027
4028          <p>The <tt class="LITERAL">:ifhp=</tt> option is used to
4029          pass options to ifhp. You can also use <tt class=
4030          "LITERAL">ifhp -Toption</tt> as well. In this example we
4031          specify a PostScript printer that does not return
4032          status.</p>
4033
4034          <div class="FIGURE">
4035            <a name="AEN1033"></a>
4036
4037            <p><b>Figure 5-19. Example of ifhp Operation</b></p>
4038<pre class="SCREEN">
4039    h110: {205} %  lpr /tmp/f.pdf
4040    h110: {205} %  lpq -L
4041     Filter_status: using model 'DEFAULT' at 09:36:36.475
4042     Filter_status: pagecount using 'pjl info pagecount' at 09:36:36.477
4043     Filter_status: setting up printer at 09:36:36.477
4044     Filter_status: getting sync using 'pjl echo' at 09:36:36.477
4045     Filter_status: sync done at 09:36:38.335
4046     Filter_status: pagecounter 105340 after 1 attempts at 09:36:38.349
4047     Filter_status: pagecounter 105340 at 09:36:38.349
4048     Filter_status: sending job file at 09:36:38.350
4049     Filter_status: starting transfer at 09:36:38.350
4050     Filter_status: file program = '/usr/bin/file -' at 09:36:38.350
4051     Filter_status: started FILE_UTIL- 'file' at 09:36:38.351
4052     Filter_status: file information = 'pdf_document,_version_1.2' at 09:36:38.415
4053     Filter_status: initial job type 'pdf_document,_version_1.2' at 09:36:38.415
4054     Filter_status: decoded job type 'POSTSCRIPT' at 09:36:38.415
4055     Filter_status: job type 'POSTSCRIPT', converter '/usr/local/bin/pdf2ps - -'
4056         at 09:36:38.415
4057     Filter_status: started CONVERTER- 'pdf2ps' at 09:36:38.416
4058     Filter_status: converter done, output 707742 bytes at 09:36:39.589
4059     Filter_status: transferring 707742 bytes at 09:36:39.590
4060     Filter_status: 26 percent done at 09:36:40.338
4061     Filter_status: 52 percent done at 09:36:41.082
4062     Filter_status: 78 percent done at 09:36:41.830
4063     Filter_status: data sent at 09:36:44.501
4064     Filter_status: sent job file at 09:36:44.501
4065     Filter_status: getting end using 'pjl job/eoj' at 09:36:44.501
4066     Filter_status: end of job detected at 09:43:50.268
4067     Filter_status: pagecounter 105359 after 1 attempts at 09:43:51.503
4068     Filter_status: pagecounter 105359, pages 19 at 09:43:51.504
4069     Filter_status: done at 09:43:51.504
4070</pre>
4071          </div>
4072
4073          <p>As you can see the information produced by the <b
4074          class="APPLICATION">ifhp</b> filter is more than adequate
4075          for tracing its steps. You might want to try adding <tt
4076          class="LITERAL">:ifhp=debug=1</tt>, <tt class=
4077          "LITERAL">:ifhp=debug=2</tt>, or even for the customary
4078          debugging information.</p>
4079
4080          <div class="FIGURE">
4081            <a name="AEN1041"></a>
4082
4083            <p><b>Figure 5-20. Using -Z to Pass Options to
4084            ifhp</b></p>
4085<pre class="SCREEN">
4086    h110: {227} % lpr -Zlandscape,duplex,copies=3 /tmp/hi
4087    
4088    Standard <b class="APPLICATION">ifhp</b> Options:
4089    
4090    Paper/Media Selection:
4091      a3, a4, a5, ledger, legal, letter
4092      envelope, oversize, transparency
4093      mediaselect=N
4094    
4095    Input Selection:
4096     inlower, inupper, manual
4097    
4098    Output Selection:
4099      outlower, outupper
4100    
4101    Copies:
4102      copies=N
4103    
4104    Orientation:
4105      landscape, portrait
4106    
4107    Duplex:
4108      duplex, duplexshort, simplex, lduplex, sduplex
4109</pre>
4110          </div>
4111
4112          <p>Job formatting options are passed to <tt class=
4113          "LITERAL">ifhp</tt> using the <b class=
4114          "APPLICATION">lpr</b> <tt class="LITERAL">-Z</tt>. These
4115          are put into the control file with the -Z option.</p>
4116
4117          <div class="FIGURE">
4118            <a name="AEN1050"></a>
4119
4120            <p><b>Figure 5-21. Testing ifhp Operations</b></p>
4121<pre class="SCREEN">
4122    #!/bin/sh
4123    # sendhp.sh
4124    cp /dev/null /tmp/log
4125    cp /dev/null /tmp/out
4126    IP=10.0.0.14
4127    ifhp=/usr/libexec/filters/ifhp
4128    # $ifhp -Tdev=$IP%9100,trace,debug=4 &lt;/tmp/one.ps 2&gt;&amp;1 | tee /tmp/log
4129    # $ifhp -Tdev=$IP%9100,trace,debug=1,appsocket,status,pagecount,waitend &lt;/tmp/one.ps 2&gt;&amp;1 | tee /tmp/log
4130    # $ifhp -Tdev=$IP%9100,trace,debug=1,pagecount_poll=2 &lt;/tmp/one.ps 2&gt;&amp;1 | tee /tmp/log
4131    $ifhp -Tdev=/tmp/out,trace,model=hp5 &lt;/tmp/one.ps 2&gt;&amp;1 | tee /tmp/log
4132    
4133    h110: {475} % sh /tmp/sendhp.sh
4134    ifhp 06:48:04.430 [3438] main: using model 'hp5'
4135    ifhp 06:48:04.433 [3438] Process_job: setting up printer
4136    ifhp 06:48:04.433 [3438] Do_accounting: pagecounter 0
4137    ifhp 06:48:04.434 [3438] Process_job: sending job file
4138    ifhp 06:48:04.434 [3438] Send_job: starting transfer
4139    ifhp 06:48:04.434 [3438] Send_job: initial job type 'POSTSCRIPT'
4140    ifhp 06:48:04.434 [3438] Send_job: decoded job type 'POSTSCRIPT'
4141    ifhp 06:48:04.434 [3438] Send_job: job type 'POSTSCRIPT'
4142    ifhp 06:48:04.434 [3438] Send_job: transferring 145 bytes
4143    ifhp 06:48:04.434 [3438] Send_job: 100 percent done
4144    ifhp 06:48:04.434 [3438] Send_job: data sent
4145    ifhp 06:48:04.434 [3438] Process_job: sent job file
4146    ifhp 06:48:04.434 [3438] Do_accounting: pagecounter 0, pages 0
4147    ifhp 06:48:04.434 [3438] Process_job: done
4148    
4149    h110: {475} % more /tmp/out
4150    ^[%-12345X@PJL
4151    @PJL RDYMSG DISPLAY = ":"
4152    @PJL USTATUSOFF
4153    @PJL USTATUS JOB = ON
4154    ...
4155</pre>
4156          </div>
4157
4158          <p>You can test <b class="APPLICATION">ifhp</b> and see
4159          what it does by using the <tt class="LITERAL">-T</tt>
4160          command line option. This is equivalent to using the <tt
4161          class="FILENAME">/etc/printcap</tt> <tt class=
4162          "LITERAL">ifhp</tt> option.&#13;</p>
4163        </div>
4164
4165        <div class="SECT1">
4166          <hr>
4167
4168          <h1 class="SECT1"><a name="AEN1059">5.3. Taming the Wild
4169          Phaser Printer</a></h1>
4170
4171          <p>There are several printers that have network
4172          interfaces but which require very special treatment.
4173          Among these printers are the Tektronics <tt class=
4174          "LITERAL">Phaser</tt> printers, some legacy Xerox
4175          printers, and some plotters. These devices require that
4176          the network connection be opened and closed multiple
4177          times when sending a job. In order to handle this we have
4178          the <i class="EMPHASIS">filter</i> open the connection.
4179          This type of operations is called the <tt class=
4180          "LITERAL">appsocket</tt> protocol.</p>
4181
4182          <div class="FIGURE">
4183            <a name="AEN1065"></a>
4184
4185            <p><b>Figure 5-22. Phaser/Appsocket Support</b></p>
4186<pre class="SCREEN">
4187    Printcap:
4188    lp:
4189      :lp=/dev/null
4190      :filter=/.../ifhp
4191      :ifhp=model=phaser  # OR
4192      :ifhp=appsocket,status,pagecount,waitend,dev=10.0.0.14%9100
4193    
4194    Offline Test:
4195    
4196    IP=10.0.0.14
4197    ifhp -Tdev=trace,debug=1,appsocket,status,pagecount,waitend,dev=10.0.0.14%9100
4198      &lt;/tmp/one.ps 2&gt;&amp;1 | tee /tmp/log
4199</pre>
4200          </div>
4201          &#13;<br>
4202          <br>
4203
4204          <p>You need to specify the remote host and port to use to
4205          the <tt class="LITERAL">ifhp</tt> filter, as well as the
4206          <tt class="LITERAL">appsocket</tt> option. You should
4207          test this first using the offline test mode.</p>
4208        </div>
4209      </div>
4210
4211      <div class="CHAPTER">
4212        <hr>
4213
4214        <h1><a name="AEN1071">Chapter 6. Banner Pages and
4215        Accounting</a></h1>
4216
4217        <p>Banner pages are usually a waste of paper unless you
4218        need to make sure that user jobs are separated clearly.
4219        Even then, unless banner pages are on different stock or
4220        color they are usually ignored and thrown away.</p>
4221
4222        <div class="SECT1">
4223          <hr>
4224
4225          <h1 class="SECT1"><a name="AEN1074">6.1. Suppressing
4226          Banner Pages</a></h1>
4227
4228          <p>Most users do not <i class="EMPHASIS">want</i> banner
4229          pages, as they are a waste of paper. Some printers,
4230          especially the HP family of printers, will generate a
4231          banner page when you send a job to them using the <tt
4232          class="LITERAL">lpd</tt> protocol (i.e. <tt class=
4233          "LITERAL">lp=port@host</tt>.</p>
4234
4235          <div class="FIGURE">
4236            <a name="NB1"></a>
4237
4238            <p><b>Figure 6-1. Changing JetDirect
4239            Configuration</b></p>
4240<pre class="SCREEN">
4241    h110: {492} % telnet 10.0.0.14
4242    Trying 10.0.0.14...
4243    Connected to h14.private.
4244    Escape character is '^]'.
4245     
4246    Please type [Return] two times, to initialize telnet configuration
4247    For HELP type "?"
4248    &gt; ?
4249     
4250    ===JetDirect Telnet Configuration===
4251     
4252            Configured Parameters
4253            IP Address      : 10.0.0.14
4254            Subnet Mask     : 255.255.255.0
4255            Default Gateway : 10.0.0.1
4256            Syslog Server   : 0.0.0.0
4257            Idle Timeout    : 121 Seconds
4258            Banner          : 1
4259    &gt; banner: 0
4260    &gt; quit
4261</pre>
4262          </div>
4263
4264          <p>Your first line of defense is to try to disable banner
4265          printing by the printer. This can be done (for HP
4266          Printers) as in <a href="#NB1">Figure 6-1</a>. Note that
4267          the user name and password are not set by default so
4268          effectively anybody can modify your printer
4269          configuration.</p>
4270
4271          <div class="FIGURE">
4272            <a name="AEN1085"></a>
4273
4274            <p><b>Figure 6-2. Printcap Option <tt class=
4275            "LITERAL">:sh</tt> and lpr -h (No Header)
4276            Option</b></p>
4277<pre class="SCREEN">
4278    Printcap:
4279      lp: ... :sh
4280    
4281    Command line:
4282      h110: {838} % lpr -h /tmp/hi
4283    
4284    No 'L' line in control file
4285</pre>
4286          </div>
4287
4288          <p>The banner printing is triggered by the <tt class=
4289          "LITERAL">L</tt> (Login name?) line in the control file.
4290          You can use the printcap <tt class="LITERAL">:sh</tt>
4291          (suppress header pages or banner pages) or the command
4292          line <b class="APPLICATION">lpr</b> <tt class=
4293          "LITERAL">-h</tt> option to prevent <b class=
4294          "APPLICATION">lpr</b> from putting this line into the
4295          control file.</p>
4296
4297          <div class="FIGURE">
4298            <a name="AEN1096"></a>
4299
4300            <p><b>Figure 6-3. Removing Banner Lines</b></p>
4301<pre class="SCREEN">
4302    Printcap:
4303    lp:...
4304    :incoming_control_filter=/.../nobanner
4305    
4306    
4307    nobanner Script:
4308    
4309    #!/usr/bin/perl
4310    ...
4311    See <a href="#FILTERTEMPLATE">Figure 5-9</a>
4312      
4313      # read stdin
4314      my( $file );
4315      $file = join "", &lt;STDIN&gt;;
4316      $file =~ s/^L.*$//m;
4317      print $file;
4318      exit 0
4319</pre>
4320          </div>
4321        </div>
4322
4323        <div class="SECT1">
4324          <hr>
4325
4326          <h1 class="SECT1"><a name="AEN1100">6.2. Forcing Banner
4327          Pages</a></h1>
4328
4329          <p>The <tt class="LITERAL">:ab</tt> (always print a
4330          banner page) is used by the <b class=
4331          "APPLICATION">lpd</b> server to force banner page
4332          generation. Even if the user tries to suppress it, it
4333          will still try to print a banner page.</p>
4334
4335          <div class="FIGURE">
4336            <a name="AEN1105"></a>
4337
4338            <p><b>Figure 6-4. Forcing Banner Pages</b></p>
4339<pre class="SCREEN">
4340    lp:...
4341    
4342    lp:server
4343      :ab   # force a banner page on printing
4344</pre>
4345          </div>
4346        </div>
4347
4348        <div class="SECT1">
4349          <hr>
4350
4351          <h1 class="SECT1"><a name="AEN1108">6.3. Generating
4352          Banner Pages</a></h1>
4353
4354          <div class="FIGURE">
4355            <a name="AEN1110"></a>
4356
4357            <p><b>Figure 6-5. Generating Banner Page</b></p>
4358<pre class="SCREEN">
4359    lp:
4360      :of=/.../ifhp
4361      :bp=/.../banner.ps  # for banner at start
4362      # :be=/.../banner.ps  # for banner at end
4363      # :bs=/.../banner.ps  # for banner at start
4364    
4365    <b class="APPLICATION">LPRng</b> banner generators:
4366      /usr/local/libexec/filters/psbanner - PostScript
4367      /usr/local/libexec/filters/pclbanner - PCL
4368      /usr/local/libexec/filters/lpbanner - Text
4369</pre>
4370          </div>
4371
4372          <p>If you want to have a banner page printed you need to
4373          have two additional <b class="APPLICATION">lpd</b>
4374          facilities in the printcap entry: a banner printing
4375          program (<tt class="LITERAL">:bp=...</tt>) and a filter
4376          to handle banner printing (<tt class=
4377          "LITERAL">:of=...</tt>). The <tt class="LITERAL">bp</tt>
4378          causes the banner to be put at the start of the job, the
4379          <tt class="LITERAL">be</tt> at the end of the job
4380          (overrides <tt class="LITERAL">bp</tt>), and you can use
4381          <tt class="LITERAL">bs</tt> and <tt class=
4382          "LITERAL">be</tt> to have banners at both start and end
4383          of jobs.</p>
4384
4385          <p>The banner printing programs are run exactly as a
4386          normal filter program, and the output is used as the
4387          banner to be printed. The <b class=
4388          "APPLICATION">LPRng</b> <b class=
4389          "APPLICATION">psbanner</b>, <b class=
4390          "APPLICATION">pclbanner</b>, and <b class=
4391          "APPLICATION">lpbanner</b> programs can be modified for
4392          local use.</p>
4393
4394          <p>If your printer requires special setup or
4395          conditioning, then you will have to specify a filter for
4396          the banner program. Historically this is done using the
4397          <tt class="LITERAL">of</tt> option. This filter is
4398          started, the banner page sent to it, and then the filter
4399          is suspended (don't ask), the job is printed, and then
4400          the filter is restarted. Finally, if a banner is needed
4401          at the end of the job it is generated and sent.</p>
4402        </div>
4403
4404        <div class="SECT1">
4405          <hr>
4406
4407          <h1 class="SECT1"><a name="AEN1130">6.4.
4408          Accounting</a></h1>
4409
4410          <p>For a detailed discussion of accounting, please
4411          consult the <b class="APPLICATION">LPRng</b> HOWTO
4412          documentation. We will briefly cover some simple recipes
4413          for disaster here.</p>
4414
4415          <div class="FIGURE">
4416            <a name="AEN1134"></a>
4417
4418            <p><b>Figure 6-6. Basic Accounting Information</b></p>
4419<pre class="SCREEN">
4420    
4421    lp: 
4422      :af=acct    # accounting file
4423        or
4424          :af=|/...       # filter to run
4425          :af=host%port   # remote server to query
4426      :as=jobstart $H $n $P $k $b $t   # line to print
4427      :as=/...    # filter to run at start of job
4428      :ae=jobend $H $n $P $k $b $t   # line to print
4429      :ae=/...    # filter to run at start of job
4430    
4431      :achk       # check to see if allowed to print
4432</pre>
4433          </div>
4434
4435          <p>The <tt class="LITERAL">:af</tt> entry specifies
4436          either a file, a network connection, or a program to run.
4437          If a file, then accounting information is written to the
4438          file; if a program, then the program is run; if a network
4439          connection then a TCP/IP connection is made to the
4440          specified host and port. The <tt class="LITERAL">:as</tt>
4441          and <tt class="LITERAL">:ae</tt> entries specify the
4442          format of the line to print or a program to run at the
4443          start and end of the job respectively.</p>
4444
4445          <div class="FIGURE">
4446            <a name="AEN1141"></a>
4447
4448            <p><b>Figure 6-7. Accounting File Information</b></p>
4449<pre class="SCREEN">
4450    jobstart '-Hh110.private' '-npapowell' '-Pt1' '-kcfT456h110.private'
4451       '-b3' '-t2001-10-21-15:17:12.000'
4452    jobend '-Hh110.private' '-npapowell' '-Pt1' '-kcfT456h110.private'
4453        '-b3' '-t2001-10-21-15:17:
4454</pre>
4455          </div>
4456
4457          <p>The accounting information provided by the <b class=
4458          "APPLICATION">lpd</b> server is very basic and does not
4459          include page usage. However, we can have the print
4460          filters write information to the file as well.</p>
4461
4462          <div class="FIGURE">
4463            <a name="AC2"></a>
4464
4465            <p><b>Figure 6-8. Filter Accounting Information</b></p>
4466<pre class="SCREEN">
4467     
4468    jobstart '-Hh110.private' '-nroot' '-Plp' '-kcfA129h110.private'
4469       '-b48780' '-t2001-10-19-09:36:36.000'
4470    filestart '-q26132' '-p105340' '-t2001-10-19-09:36:38.350'
4471        '-Aroot@h110+129' '-nroot' '-Plp'
4472    fileend '-b19' '-T435' '-q26132' '-p105359' '-t2001-10-19-09:43:51.504'
4473         '-Aroot@h110+129' '-nroot' '-Plp'
4474    jobend '-Hh110.private' '-nroot' '-Plp' '-kcfA129h110.private' '-b48780' '-t2001-10-19-09:43:51.000'
4475</pre>
4476          </div>
4477
4478          <p>The <tt class="LITERAL">filestart</tt> and <tt class=
4479          "LITERAL">fileend</tt> lines were written by the <b
4480          class="APPLICATION">ifhp</b> filter. The <tt class=
4481          "LITERAL">-p</tt> (pagecounter) values are the starting
4482          and ending values for the physical page counter on the
4483          printer. The <tt class="LITERAL">-b</tt> value is the
4484          number of pages used and the <tt class="LITERAL">-T</tt>
4485          the number of seconds used.</p>
4486
4487          <p>Remember that <b class="APPLICATION">ifhp</b> can only
4488          get accurate page counting information if there is a
4489          physical page counter and it can be accurately read. This
4490          requires a bidirectional network link. Parallel ports <i
4491          class="EMPHASIS">do not work</i>. Also, your printer must
4492          support either PJL or PostScript, and have a hardware
4493          page counter. Finally, the page counter must be updated
4494          in a timely manner and reflect the number of pages used
4495          by each job.</p>
4496
4497          <p>The <tt class="LITERAL">:achk</tt> checks to see if
4498          the user has permission to print. At the start of the
4499          job, if the accounting destination is a program or
4500          network connection, after writing the information <b
4501          class="APPLICATION">lpd</b> reads a line from program or
4502          connection. This line is used to determine if the user
4503          has permission to print. The return value can also cause
4504          the job to be held or deleted.</p>
4505        </div>
4506
4507        <div class="SECT1">
4508          <hr>
4509
4510          <h1 class="SECT1"><a name="AEN1162">6.5. Accounting
4511          Gotchas</a></h1>
4512
4513          <div class="FIGURE">
4514            <a name="AC3"></a>
4515
4516            <p><b>Figure 6-9. Accounting Gotchas</b></p>
4517<pre class="SCREEN">
4518    jobstart '-Hh110.private' '-nroot' '-Plp' '-kcfA129h110.private'
4519       '-b48780' '-t2001-10-19-09:36:36.000'
4520    filestart '-q26132' '-p105340' '-t2001-10-19-09:36:38.350'
4521        '-Aroot@h110+129' '-nroot' '-Plp'
4522    jobstart '-Hh110.private' '-nroot' '-Plp' '-kcfA129h110.private'
4523       '-b49780' '-t2001-10-19-09:36:36.000'
4524    filestart '-q27992' '-p105340' '-t2001-10-19-09:36:38.350'
4525        '-Aroot@h110+129' '-nroot' '-Plp'
4526</pre>
4527          </div>
4528
4529          <p>Observe the accounting file in <a href="#PP1">Figure
4530          7-1</a>. Clearly something has happened. The clever
4531          student (ummm... user?) has killed off the printer just
4532          as his last page has come out. There is no usage line.
4533          You will have to calculate usage based on the differences
4534          between the pagecounters at the start of each job.</p>
4535
4536          <p>Of course, this can also be the result of a printer
4537          failure, bad print job, etc. etc. etc. Not to mention
4538          elves. Most student labs have lots of elves lurking in
4539          the background that cause endless headaches.</p>
4540        </div>
4541
4542        <div class="SECT1">
4543          <hr>
4544
4545          <h1 class="SECT1"><a name="AEN1170">6.6. Accounting
4546          Including Banner Pages</a></h1>
4547
4548          <div class="FIGURE">
4549            <a name="AEN1172"></a>
4550
4551            <p><b>Figure 6-10. Accounting Using Banner
4552            Pages</b></p>
4553<pre class="SCREEN">
4554    lp:
4555      :of=/.../ifhp
4556      :...
4557</pre>
4558          </div>
4559
4560          <p>The <tt class="LITERAL">:of</tt> filter is used to
4561          print the banner pages. Now the information in the
4562          accounting file inclues the banner pages as well as the
4563          job pages.</p>
4564        </div>
4565      </div>
4566
4567      <div class="CHAPTER">
4568        <hr>
4569
4570        <h1><a name="AEN1177">Chapter 7. Printer Pools and Load
4571        Sharing</a></h1>
4572
4573        <div class="FIGURE">
4574          <a name="PP1"></a>
4575
4576          <p><b>Figure 7-1. Printer Pools and Load Sharing</b></p>
4577
4578          <div class="MEDIAOBJECT">
4579            <p><img src="pooling.png"></p>
4580          </div>
4581        </div>
4582
4583        <p>A printer pool does load sharing amoung a group of
4584        printers. When you send a job to the main spool queue the
4585        job is then sent to the next available printer. If all of
4586        the printers are busy then the job is held in the queue <a
4587        href="#PP1">Figure 7-1</a>.</p>
4588
4589        <div class="FIGURE">
4590          <a name="PP2"></a>
4591
4592          <p><b>Figure 7-2. Load Balancing Printcap</b></p>
4593<pre class="SCREEN">
4594    main:
4595      :sd=/var/spool/lpd/%P:sv=sv1,sv2,sv3
4596    
4597    sv1:
4598      :sd=/var/spool/lpd/%P:ss=main:lp=...
4599    sv2:
4600      :sd=/var/spool/lpd/%P:ss=main:lp=...
4601    sv3:
4602      :sd=/var/spool/lpd/%P:ss=main:lp=...
4603</pre>
4604        </div>
4605
4606        <p>The printcap for setting up spooling is shown in <a
4607        href="#PP2">Figure 7-2</a>. The <tt class=
4608        "LITERAL">:sv</tt> option marks this queue as the input
4609        queue for load balancing and the <tt class=
4610        "LITERAL">:ss</tt> option specifies that this queue is the
4611        destination for load balancing. The server queues must have
4612        an associated device and send the jobs to the associated
4613        device.</p>
4614
4615        <div class="FIGURE">
4616          <a name="AEN1193"></a>
4617
4618          <p><b>Figure 7-3. Load Balancing to Remote Queues</b></p>
4619
4620          <div class="MEDIAOBJECT">
4621            <p><img src="chooser.png"></p>
4622          </div>
4623        </div>
4624
4625        <div class="FIGURE">
4626          <a name="AEN1198"></a>
4627
4628          <p><b>Figure 7-4. Printcap for Chooser</b></p>
4629<pre class="SCREEN">
4630    main:
4631      # program to select destination
4632      :chooser=/.../chooser
4633      :destinations=s1@host1,s2@host2,s3@host3
4634      # You can even combine the two forms
4635      #  sv=...
4636</pre>
4637        </div>
4638
4639        <p>The <tt class="LITERAL">:chooser</tt> value is an
4640        executable program that is provided a list of destinations,
4641        by using the <tt class="LITERAL">:destinations</tt> value
4642        in the <tt class="LITERAL">$PRINTCAP_ENTRY</tt>. We will
4643        show how to use this in the next section.</p>
4644
4645        <div class="SECT1">
4646          <hr>
4647
4648          <h1 class="SECT1"><a name="AEN1205">7.1. Implementing
4649          Smart Load Balancing</a></h1>
4650
4651          <div class="FIGURE">
4652            <a name="AEN1207"></a>
4653
4654            <p><b>Figure 7-5. Chooser Program Operation</b></p>
4655<pre class="SCREEN">
4656    # In Perlish
4657    @list = PC('destination');  # get destination list
4658    foreach $printer (@list) {
4659        if( PrinterAvailable( $printer ){
4660            print $printer . "\n";
4661            last;
4662        }
4663    }
4664</pre>
4665          </div>
4666
4667          <p>The <tt class="LITERAL">PrinterAvailable</tt> function
4668          would determine the availability of the destination
4669          printer by an appropriate method - <b class=
4670          "APPLICATION">lpq</b> query, testing to see if a
4671          connection can be made to the device, etc.</p>
4672
4673          <p>If you specify a <tt class="LITERAL">:chooser</tt> for
4674          a <tt class="LITERAL">:sv</tt> type of load balance
4675          queue, then the chooser program can also be used. Lets
4676          look at a simple <tt class="LITERAL">chooser</tt>
4677          implementation.</p>
4678
4679          <div class="FIGURE">
4680            <a name="AEN1217"></a>
4681
4682            <p><b>Figure 7-6. Filter Template in Perl</b></p>
4683<pre class="SCREEN">
4684    #!/usr/bin/perl
4685    use Getopt::Std;
4686    my $debug = 1;    # always... sigh...
4687    my(%opt, @pc, %options);
4688    
4689    # get command line options
4690    getopts( 'A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:T:S:U:V:W:X:Y:Z:'
4691    . 'a:b:cd:e:f:g:h:i:j:k:l:m:n:o:p:q:r:t:s:u:v:w:x:y:z:', \%opt );
4692    while( @ARGV ){ $opt{acct} = pop @ARGV ; };
4693    
4694    # split up the PRINTCAP_ENTRY environment variable value
4695    @pc = split /\n\s*:/s, ($ENV{PRINTCAP_ENTRY} || "");
4696    shift @pc;  # throw way first entry field, printer name
4697    # set the options
4698    foreach (@pc){ # set the options values
4699        if( /^(.+)=(.*)/ ){ $options{$1} = $2;
4700        } elsif ( /^(.+)@/ ){ $options{$1} = 0;
4701        } else { $options{$_} = 1; }
4702    }
4703    
4704    if( $debug ){ # for those interested
4705        my $s = "";
4706        foreach my $v (sort keys %options ){ $s .= "$v='$options{$v}',"; }
4707        print STDERR "Printcap: '$s'\n";
4708        $s="";
4709        foreach my $v (sort keys %opt){ $s .= "$v='$opt{$v}',"; }
4710        print STDERR "Args: '$s'\n";
4711    }
4712   
4713</pre>
4714          </div>
4715
4716          <p>This is the standard filter template. We use this
4717          almost everywhere.</p>
4718
4719          <div class="FIGURE">
4720            <a name="AEN1222"></a>
4721
4722            <p><b>Figure 7-7. Choosing A Destintation</b></p>
4723<pre class="SCREEN">
4724    my (@list, @destinations);
4725    if( $options{sv} ){ # if we have :sv then we read them from STDIN
4726        while( &lt;STDIN&gt; ){ chomp; push @destinations, $_; }
4727    } else { # else we use the 'destinations' printcap value
4728        @list = split /[,\s]+/, ($options{destinations} || "");
4729        # and we randomize - this is a bit of perl magic
4730        while( @list ){
4731            push @destinations,(splice @list,rand(@list),1);
4732        }
4733    }
4734    # and we split the destinations up...
4735    print STDERR "Destinations '@destinations'\n" if $debug;
4736    # and now we search
4737    my $lpq="/usr/bin/lpq";
4738    foreach ( @destinations ){
4739        my $status = "";
4740        next if not $_;
4741        # run the lpq
4742        eval { alarm(10); $status = `$lpq -s -P$_`; }; alarm(0);
4743        chomp $status;
4744        print STDERR "STATUS '$_' $status\n" if $debug;;
4745        # we reject queues that are not suitable
4746        next if( $status =~ /disabled/ or $status != / 0 jobs / );
4747        print STDERR "chose '$_' from @$destinations\n";
4748        print $_;
4749        last;
4750    }
4751</pre>
4752          </div>
4753
4754          <p>We first get the list of destinations - from <tt
4755          class="LITERAL">STDIN</tt> if we have helping an <tt
4756          class="LITERAL">:sv</tt> load balance queue, or from the
4757          <tt class="LITERAL">:destinations</tt> printcap entry. In
4758          the later case we randomize the list so that we spread
4759          the load over different printers rather than sending to
4760          the first printer in the list. We then run a command or
4761          application that gets the print queue status or whatever
4762          we need to decide if the printer is ready. Notice the
4763          timeouts. This is usually not necessary but you might run
4764          into this problem some day. We then look at the status
4765          and decide if we can use the printer.</p>
4766
4767          <p>If no printer is available then nothing is printed on
4768          <tt class="LITERAL">STDOUT</tt>, and the <b class=
4769          "APPLICATION">lpd</b> process will wait until either a
4770          printer becomes available or for a timeout specified by
4771          the <tt class="LITERAL">:chooser_interval</tt> value
4772          (default 10 seconds) in the printcap entry or <tt class=
4773          "FILENAME">/etc/lpd.conf</tt> file.</p>
4774        </div>
4775
4776        <div class="SECT1">
4777          <hr>
4778
4779          <h1 class="SECT1"><a name="AEN1234">7.2. Using <tt class=
4780          "LITERAL">:chooser</tt> Exit Codes</a></h1>
4781
4782          <div class="FIGURE">
4783            <a name="AEN1237"></a>
4784
4785            <p><b>Figure 7-8. Chooser Exit Codes</b></p>
4786<pre class="SCREEN">
4787    Exit Code                Action
4788    0 (JSUCC)                Use chooser output for destination
4789                             (No destination, retry later)
4790    1 (JFAIL)                Failed - retry later
4791                             (same as JSUCC, no destination)
4792    2 (JABORT)               Abort printing, wait for restart
4793    3 (JREMOVE)              Remove job
4794    4 (JHOLD)                Set job HOLD flag
4795</pre>
4796          </div>
4797
4798          <p>The <tt class="LITERAL">:chooser</tt> program exit
4799          codes can be used to control printing. The <tt class=
4800          "LITERAL">JHOLD</tt> and <tt class="LITERAL">JREMOVE</tt>
4801          exit codes are job specific; they can be used to hold or
4802          remove a job.</p>
4803        </div>
4804      </div>
4805
4806      <div class="CHAPTER">
4807        <hr>
4808
4809        <h1><a name="AEN1244">Chapter 8. Wildcards, Bounce Queues,
4810        and Forwarding</a></h1>
4811
4812        <p>One of the things you might want to do is have a set of
4813        queues that massage the various jobs and then send them to
4814        a destination printer.</p>
4815
4816        <div class="FIGURE">
4817          <a name="AEN1247"></a>
4818
4819          <p><b>Figure 8-1. Evil (BAD) Way</b></p>
4820<pre class="SCREEN">
4821    landscape:force_localhost
4822      :ifhp=model=xx
4823      :filter=/.../convert_to_landscape | /.../ifhp
4824      :lp=10.0.0.14%9100
4825    
4826    portrait:force_localhost
4827      :ifhp=model=xx
4828      :filter=/.../convert_to_landscape | /.../ifhp
4829      :lp=10.0.0.14%9100
4830    
4831    lp:tc=.common
4832      :ifhp=model=xx
4833      :filter=/.../ifhp
4834      :lp=10.0.0.14%9100
4835</pre>
4836        </div>
4837
4838        <p>Each queue will now fight for a connection to the
4839        destination printer.</p>
4840
4841        <div class="SECT1">
4842          <hr>
4843
4844          <h1 class="SECT1"><a name="AEN1251">8.1. Bounce
4845          Queues</a></h1>
4846
4847          <div class="FIGURE">
4848            <a name="AEN1253"></a>
4849
4850            <p><b>Figure 8-2. Not So Evil Way</b></p>
4851<pre class="SCREEN">
4852    landscape:tc=.common
4853      :filter=/.../convert_to_landscape
4854      :lp=lp@localhost
4855    
4856    portrait:tc=.common
4857      :filter=/.../convert_to_landscape
4858      :lp=lp@localhost
4859    
4860    lp:tc=.common
4861      :ifhp=model=xx
4862      :filter=/.../ifhp
4863      :lp=10.0.0.14%9100
4864</pre>
4865          </div>
4866
4867          <p>You have various filters set up so that each queue
4868          does a conversion and then forwards it to the real
4869          printer for output. No fighting. This method is called <i
4870          class="EMPHASIS">bounce queues</i> as the job <i class=
4871          "EMPHASIS">bounces</i> through the <i class=
4872          "EMPHASIS">queues</i>, getting modified at each
4873          stage.</p>
4874        </div>
4875
4876        <div class="SECT1">
4877          <hr>
4878
4879          <h1 class="SECT1"><a name="AEN1260">8.2. Adding -Z
4880          Options Using Bounce Queues</a></h1>
4881
4882          <div class="FIGURE">
4883            <a name="AEN1262"></a>
4884
4885            <p><b>Figure 8-3. Add Options Using <tt class=
4886            "LITERAL">:append_z</tt></b></p>
4887<pre class="SCREEN">
4888    landscape:tc=.common
4889      :append_z=landscape
4890      :lp=lp@localhost
4891    
4892    portrait:tc=.common
4893      :append_z=portrait
4894      :lp=lp@localhost
4895    
4896    # ifhp (or other) filter uses the -Z options
4897    lp:tc=.common
4898      :ifhp=model=xx
4899      :filter=/.../ifhp
4900      :lp=10.0.0.14%9100
4901</pre>
4902          </div>
4903
4904          <p>Now you can add one option at a time. But what if you
4905          want to do landscape and duplex mode at the same time?
4906          You need to create a <tt class=
4907          "LITERAL">landscape_duplex</tt> queue. The combinations
4908          become very unweildy.</p>
4909        </div>
4910
4911        <div class="SECT1">
4912          <hr>
4913
4914          <h1 class="SECT1"><a name="INCOMING">8.3. Adding Options
4915          By Modifying Control File</a></h1>
4916
4917          <div class="FIGURE">
4918            <a name="AEN1270"></a>
4919
4920            <p><b>Figure 8-4. Diabolically Fiendishly Clever
4921            Method</b></p>
4922<pre class="SCREEN">
4923    .common=force_localhost:sd=/var/spool/lpd/%P:sh:mx=0
4924    
4925    lp|lp_*  # we recognize lp_xxxx for this filter
4926      :tc=.common
4927      :incoming_control_filter=/.../update_z
4928      :ifhp=model=xx
4929      :filter=/.../ifhp
4930      :lp=10.0.0.14%9100
4931    
4932    -- for landscape:
4933    h110: {838} % lpr -Plp_landscape
4934       -&gt; Control file:  Zlandscape
4935    
4936    -- for portrait
4937    h110: {838} % lpr -Plp_portrait
4938       -&gt; Control file:  Zlandscape
4939    
4940    -- for landscape and duplex
4941    h110: {838} % lpr -Plp_landscape_duplex -Zother
4942       -&gt; Control file:  Zother,landscape,duplex
4943</pre>
4944          </div>
4945
4946          <p>You can use a <i class="EMPHASIS">wildcard</i> in the
4947          printer name. The <b class="APPLICATION">LPRng</b> code
4948          will first try to match a printer name against the
4949          non-wildcard printer names. If this fails then it will
4950          look for the first match using a <i class=
4951          "EMPHASIS">glob</i> type of match.</p>
4952
4953          <p>When the job is received the name that was used to
4954          send the job will be put into the control file as the <tt
4955          class="LITERAL">Q</tt> line and is passed as a <tt class=
4956          "LITERAL">-Q</tt> option to and filters. The <tt class=
4957          "LITERAL">:incoming_control_filter</tt> is passed the
4958          original control file on its <tt class=
4959          "LITERAL">STDIN</tt> and sends a modified version on <tt
4960          class="LITERAL">STDOUT</tt>. This allows the control file
4961          to be modified as it is received.</p>
4962
4963          <p>One of the ways to modify the control file is to
4964          convert suffixes of the print queue name (i.e. - <tt
4965          class="LITERAL">_option</tt>) to <tt class=
4966          "LITERAL">-Z</tt> option values and append these to the
4967          <tt class="LITERAL">Z</tt> line of the control file.</p>
4968
4969          <div class="FIGURE">
4970            <a name="UPDATEZ"></a>
4971
4972            <p><b>Figure 8-5. Using <tt class=
4973            "LITERAL">update_z</tt></b></p>
4974<pre class="SCREEN">
4975    #!/usr/bin/perl
4976    ...
4977      See <a href="#FILTERTEMPLATE">Figure 5-9</a>
4978    
4979    # read stdin
4980    my( $file, $Zopts, $Q );
4981    $file = join "", &lt;STDIN&gt;;
4982    print STDERR "File '$file'\n" if $debug;
4983    
4984    # first use command line Queue name, then control file Q
4985    # then the printer name, then control file P
4986    $Q = $opt{Q}; ($Q) = $file =~ /^Q(.*)$/m if not $Q;
4987    # if no queue name fall back to printer name
4988    $Q = $opt{P} if not $Q; ($Q) = $file =~ /^P(.*)$/m if not $Q;
4989    $Q = "" if not $Q;  # stupid -w... sigh...
4990    
4991    # get Zopts
4992    ($Zopts) = $file =~ /^Z(.*)$/m;
4993    $Zopts = "" if not $Zopts; # stupid -w ... sigh ...
4994    
4995    print STDERR "Q '$Q', Zopts '$Zopts'\n" if $debug;
4996    
4997    # now we split up the name and use as parameters for Z options
4998    while( $Q =~ /_([^_]+)/g ){
4999        # you can simply append them:
5000        $Zopts .= ",$1";
5001        # or you can test and then append translated format
5002        # $Zopts .= $xlate{$1} if $late{$1}
5003    }
5004    $Zopts =~ s/^,//; # remove leading comma
5005    print "Final '$Zopts'\n" if $debug;
5006    if( $Zopts ){
5007        $file = "Z$Zopts\n" . $file if( not ($file =~ s/^Z.*$/Z$Zopts/m));
5008    }
5009    print $file;
5010    exit 0
5011</pre>
5012          </div>
5013
5014          <p>The <tt class="LITERAL">-Q</tt> option or control file
5015          <tt class="LITERAL">Q</tt> line is used to get the name
5016          of the print queue. The suffixes are then processed in
5017          turn. You can either simply append them or have a hash
5018          translate these values.</p>
5019        </div>
5020      </div>
5021
5022      <div class="CHAPTER">
5023        <hr>
5024
5025        <h1><a name="AEN1295">Chapter 9. Form Support and Hold
5026        Queues</a></h1>
5027
5028        <p>Sometimes jobs require a special setup on a printer, and
5029        jobs cannot be printed unless it is done. There are several
5030        ways to handle this.</p>
5031
5032        <div class="SECT1">
5033          <hr>
5034
5035          <h1 class="SECT1"><a name="AEN1298">9.1. Hold
5036          Queues</a></h1>
5037
5038          <div class="FIGURE">
5039            <a name="AEN1300"></a>
5040
5041            <p><b>Figure 9-1. Hold Queues</b></p>
5042<pre class="SCREEN">
5043    .common=force_localhost:sd=/var/spool/lpd/%P:sh:mx=0
5044    
5045    setup1:tc=.common
5046      :ah        # always hold incoming jobs
5047      :lp=lp@localhost
5048    setup2:tc=.common
5049      :ah        # always hold incoming jobs
5050      :lp=lp@localhost
5051    lp:tc=.common  # print queue
5052      :ifhp=model=xx
5053      :filter=/.../ifhp
5054      :lp=10.0.0.14%9100
5055</pre>
5056          </div>
5057
5058          <div class="FIGURE">
5059            <a name="AEN1303"></a>
5060
5061            <p><b>Figure 9-2. All Hold Queues</b></p>
5062<pre class="SCREEN">
5063    h110: {853} % lpq -Psetup1
5064    Printer: setup1@h110 (dest t1@localhost) (autohold)
5065     Queue: no printable jobs in queue
5066    Printer: t1@h110 'Test Printer 1' (printing disabled)
5067     Queue: no printable jobs in queue
5068    h110: {854} % lpr -Psetup1 /tmp/hi
5069    h110: {855} % lpq -Psetup1
5070    Printer: setup1@h110 (dest t1@localhost) (autohold)
5071     Queue: no printable jobs in queue
5072     Holding: 1 held jobs in queue
5073     Server: no server active
5074     Rank   Owner/ID                  Class Job Files                 Size Time
5075    hold   papowell@h110+356            A   356 /tmp/hi                  3 15:02:50
5076    Printer: t1@h110 'Test Printer 1' (printing disabled)
5077     Queue: no printable jobs in queue
5078</pre>
5079          </div>
5080
5081          <p>When we print jobs to a <tt class="LITERAL">:ah</tt>
5082          or always hold queue, the job is not processed until
5083          released. We can release one or all the jobs that are
5084          being held.</p>
5085
5086          <div class="FIGURE">
5087            <a name="AEN1308"></a>
5088
5089            <p><b>Figure 9-3. Releasing Jobs for Printing</b></p>
5090<pre class="SCREEN">
5091    h110: {856} % lpc release setup1 all
5092    Printer: setup1@h110
5093    setup1: selected 'papowell@h110+356'
5094    setup1@h110.private: started
5095    h110: {857} % lpq -Psetup1
5096    Printer: setup1@h110 (dest t1@localhost) (autohold)
5097     Queue: no printable jobs in queue
5098     Status: job 'cfA356h110.private' removed at 15:03:49.053
5099    Printer: t1@h110 'Test Printer 1' (printing disabled)
5100     Queue: 1 printable job
5101     Server: no server active
5102     Rank   Owner/ID                  Class Job Files                 Size Time
5103    1      papowell@h110+356            A   356 /tmp/hi                  3 15:03:49
5104    h110: {858} %
5105</pre>
5106          </div>
5107
5108          <p>We can release the jobs which are then forwarded to
5109          the main queue for printing.</p>
5110
5111          <p>We can also set up <i class="EMPHASIS">Time
5112          Release</i> queues using the <tt class=
5113          "LITERAL">cron</tt> time scheduling system.</p>
5114
5115          <div class="FIGURE">
5116            <a name="AEN1315"></a>
5117
5118            <p><b>Figure 9-4. Releasing Jobs For Scheduled Print
5119            Run</b></p>
5120<pre class="SCREEN">
5121    Printcap:
5122      nightrun:
5123        :ah        # always hold incoming jobs
5124        :lp=lp@localhost
5125    
5126    Crontab Entry To Release Jobs:
5127    
5128    #minute hour mday month wday    who command
5129    1   3   *   *   *   root    /usr/sbin/lpc release nightrun all
5130</pre>
5131          </div>
5132
5133          <p>You can also use the <b class="APPLICATION">LPRng</b>
5134          <i class="EMPHASIS">class</i> facility. The <b class=
5135          "APPLICATION">lpr</b> <tt class="LITERAL">-Cclass</tt>
5136          option sets the <tt class="LITERAL">Cclass</tt> line in
5137          the control file. You can then use the <b class=
5138          "APPLICATION">lpc</b> <tt class="LITERAL">class</tt>
5139          facility to select job classes to print.</p>
5140
5141          <div class="FIGURE">
5142            <a name="HOLDCLASS"></a>
5143
5144            <p><b>Figure 9-5. Using Job Classes</b></p>
5145<pre class="SCREEN">
5146    h110: {870} % lpc class t1 top,middle
5147    Printer: t1@h110
5148    classes printed 'top,middle'
5149    t1@h110.private: class updated
5150    h110: {871} % lpq
5151    Printer: t1@h110 'Test Printer 1' (classes top,middle)
5152     Queue: no printable jobs in queue
5153    h110: {872} % lpr -Clow /tmp/a
5154    h110: {873} % lpq
5155    Printer: t1@h110 'Test Printer 1' (classes top,middle)
5156     Queue: no printable jobs in queue
5157     Holding: 1 held jobs in queue
5158     Server: no server active
5159     Rank   Owner/ID                  Class Job Files                 Size Time
5160    holdclass papowell@h110+451         L   451 /tmp/a               38404 15:16:39
5161    h110: {874} % lpr -Ctop /tmp/hi
5162    h110: {875} % lpq
5163    Printer: t1@h110 'Test Printer 1' (classes top,middle)
5164     Queue: no printable jobs in queue
5165     Holding: 1 held jobs in queue
5166     Server: no server active
5167     Status: job 'cfT456h110.private' removed at 15:17:12.932
5168     Rank   Owner/ID                  Class Job Files                 Size Time
5169    holdclass papowell@h110+451         L   451 /tmp/a               38404 15:16:39
5170</pre>
5171          </div>
5172
5173          <p>You can specify a current list of classes to be
5174          printed using the <b class="APPLICATION">lpc</b> <tt
5175          class="LITERAL">class</tt> command. As shown in <a href=
5176          "#HOLDCLASS">Figure 9-5</a>. the jobs not in the current
5177          classes are held until explicitly released or until the
5178          class is changed. You can disable the job class facility
5179          by setting the class to <tt class="LITERAL">off</tt>.</p>
5180
5181          <div class="FIGURE">
5182            <a name="AEN1334"></a>
5183
5184            <p><b>Figure 9-6. Setting New Job Classes and Disabling
5185            Job Classes</b></p>
5186<pre class="SCREEN">
5187    h110: {877} % lpc class t1 low
5188    Printer: t1@h110
5189    classes printed 'low'
5190    t1@h110.private: class updated
5191    h110: {879} % lpq -ll
5192    Printer: t1@h110 'Test Printer 1' (classes low)
5193     Queue: no printable jobs in queue
5194     Status: finished 'papowell@h110+451', status 'JSUCC' at 15:22:03.178
5195     Status: subserver pid 84477 exit status 'JSUCC' at 15:22:03.179
5196     Status: t1@h110.private: job 'cfL451h110.private' printed at 15:22:03.180
5197     Status: job 'cfL451h110.private' removed at 15:22:03.181
5198    
5199    h110: {39} % lpc class t1 off
5200    Printer: t1@h110
5201    all classes printed
5202    t1@h110.private: class updated
5203    h110: {40} % lpq
5204    Printer: t1@h110 'Test Printer 1'
5205     Queue: no printable jobs in queue
5206     Status: job 'cfL451h110.private' removed at 15:22:03.181
5207</pre>
5208          </div>
5209
5210          <p>You can also put a class value into the control file
5211          using the <tt class=
5212          "LITERAL">incoming_control_filter</tt> facility described
5213          in <a href="#INCOMING">Section 8.3</a>.</p>
5214
5215          <div class="FIGURE">
5216            <a name="AEN1340"></a>
5217
5218            <p><b>Figure 9-7. Modifying Control File Using
5219            update_class</b></p>
5220<pre class="SCREEN">
5221    lp|lp_*:tc=.common
5222      :incoming_control_filter=/.../update_class
5223      :ifhp=model=xx
5224      :filter=/.../ifhp
5225      :lp=10.0.0.14%9100
5226</pre>
5227          </div>
5228
5229          <p>The <tt class="LITERAL">:incoming_control_filter</tt>
5230          will now update the class to whatever you want.</p>
5231
5232          <div class="FIGURE">
5233            <a name="AEN1346"></a>
5234
5235            <p><b>Figure 9-8. The update_class Filter</b></p>
5236<pre class="SCREEN">
5237    #!/usr/bin/perl
5238    ...
5239      See <a href="#FILTERTEMPLATE">Figure 5-9</a>
5240    
5241    # read stdin
5242    my( $file, $Copts, $Q );
5243    $file = join "", &lt;STDIN&gt;;
5244    print STDERR "File '$file'\n" if $debug;
5245    
5246    # first use command line Queue name, then control file Q
5247    # then the printer name, then control file P
5248    $Q = $opt{Q}; ($Q) = $file =~ /^Q(.*)$/m if not $Q;
5249    # if no queue name fall back to printer name
5250    $Q = $opt{P} if not $Q; ($Q) = $file =~ /^P(.*)$/m if not $Q;
5251    $Q = "" if not $Q;  # stupid -w... sigh...
5252    
5253    # get Copts
5254    ($Copts) = $file =~ /^C(.*)$/m;
5255    $Copts = "" if not $Copts; # stupid -w ... sigh ...
5256    
5257    print STDERR "Q '$Q', Copts '$Copts'\n" if $debug;
5258    
5259    # now we split up the name and use as parameters for C option
5260    while( $Q =~ /_([^_]+)/g ){
5261        $Copts = $1;
5262    }
5263    print "Final '$Copts'\n" if $debug;
5264    if( $Copts ){
5265        $file = "C$Copts\n" . $file if( not ($file =~ s/^C.*$/C$Copts/m));
5266    }
5267    print $file;
5268    exit 0
5269</pre>
5270          </div>
5271        </div>
5272      </div>
5273
5274      <div class="CHAPTER">
5275        <hr>
5276
5277        <h1><a name="AEN1351">Chapter 10. Interfacing to Vintage,
5278        Legacy, and SunOS Print Spoolers</a></h1>
5279
5280        <p>Some legacy, vintage, and other print spoolers do not
5281        meet the RFC1179 requirements, or accept only control files
5282        with options used by the original BSD (1984 vintage) print
5283        spooler and only in the order used by the original BSD
5284        (1984 vintage) print spooler. The <tt class=
5285        "LITERAL">:bk</tt> (<i class="EMPHASIS">Berkely
5286        Kompatible</i>) option causes <b class=
5287        "APPLICATION">lpd</b> to generate control files compatible
5288        with this format. If you encounter problems with
5289        transferring files to these systems, try using the <tt
5290        class="LITERAL">:bk</tt> option first.</p>
5291
5292        <p>&#13;</p>
5293
5294        <div class="FIGURE">
5295          <a name="AEN1359"></a>
5296
5297          <p><b>Figure 10-1. Using <tt class="LITERAL">:bk</tt>
5298          (Berkeley Kompatible) Flag</b></p>
5299<pre class="SCREEN">
5300    lp:force_localhost@     # make control files berkeley
5301      :bk
5302      :lp=...
5303</pre>
5304        </div>
5305        &#13;<br>
5306        <br>
5307      </div>
5308
5309      <div class="CHAPTER">
5310        <hr>
5311
5312        <h1><a name="AEN1363">Chapter 11. Managing Enterprise Level
5313        Printing Systems</a></h1>
5314
5315        <p>If you are doing management of more than 20 printers,
5316        then you already know the headaches. You need to make the
5317        printers available to all/some/none of your users, each
5318        user has a different set of requirements, and no two
5319        printers are the same. The following are some helpful
5320        suggestions and recipes for managing printer
5321        information.</p>
5322
5323        <div class="SECT1">
5324          <hr>
5325
5326          <h1 class="SECT1"><a name="AEN1366">11.1. Templates and
5327          Standard Configurations</a></h1>
5328
5329          <div class="FIGURE">
5330            <a name="AEN1368"></a>
5331
5332            <p><b>Figure 11-1. Templates in Printcaps</b></p>
5333<pre class="SCREEN">
5334    .common
5335      :sh:sd=/var/spool/lpd/%P:force_localhost
5336    .hplj4
5337      :ifhp=model=hp4
5338      :filter=/.../ifhp
5339    
5340    # server information
5341    hp4:server:tc=.common,.hplj4
5342      :lp=10.0.0.14%9100
5343    
5344    #client information
5345    hp4:client:lp=%P@server1
5346</pre>
5347          </div>
5348
5349          <p>You should set up a standard set of templates to see
5350          what you have. You can then use <b class=
5351          "APPLICATION">lpc</b> to see what the printcap is.</p>
5352
5353          <div class="FIGURE">
5354            <a name="AEN1373"></a>
5355
5356            <p><b>Figure 11-2. Using lpc client all</b></p>
5357<pre class="SCREEN">
5358    .defaults
5359     :ab@
5360     ...
5361    
5362    .config
5363    
5364    .all
5365     :t1
5366     :t2
5367    
5368    #Printcap Information
5369    t1|t1_*
5370     :filter=/usr/local/libexec/filters/ifhp
5371     :lp=/var/tmp/t1_lp
5372     :sd=/var/spool/lpd/%P
5373    t2|Test Printer 2
5374     :lf=log
5375     :lp=t1@h110.private
5376     :sd=/var/spool/lpd/%P
5377</pre>
5378          </div>
5379
5380          <p>You can use <tt class="LITERAL">lpc client all</tt> to
5381          see the printcap information as the <b class=
5382          "APPLICATION">LPRng</b> clients would see it. This allows
5383          you to check out the various printcaps before you use
5384          them. You can also use <tt class="LITERAL">lpc server
5385          all</tt> to see the printcap information as the <b class=
5386          "APPLICATION">lpd</b> server would see it.</p>
5387        </div>
5388
5389        <div class="SECT1">
5390          <hr>
5391
5392          <h1 class="SECT1"><a name="AEN1383">11.2. Master Print
5393          Servers, One User Printcap</a></h1>
5394
5395          <div class="FIGURE">
5396            <a name="AEN1385"></a>
5397
5398            <p><b>Figure 11-3. Master User Printcap File, No Local
5399            Spooling</b></p>
5400<pre class="SCREEN">
5401    # Just information for clients
5402    #  list all of the printers for this server
5403    lp1|lp2|.....
5404      :client:lp=%Q@server1.private:force_localhost@
5405    lp99|....
5406      :client:lp=%Q@server2.private:force_localhost@
5407</pre>
5408          </div>
5409
5410          <p>This will allow you to send jobs directly to the print
5411          server. You use the <tt class="LITERAL">lp=%Q@server</tt>
5412          form for the destination. Note that you will need <b
5413          class="APPLICATION">LPRng</b> version 3.8.0 or later for
5414          this to work.</p>
5415        </div>
5416
5417        <div class="SECT1">
5418          <hr>
5419
5420          <h1 class="SECT1"><a name="AEN1391">11.3. Master Print
5421          Servers, Local Spooling</a></h1>
5422
5423          <div class="FIGURE">
5424            <a name="AEN1393"></a>
5425
5426            <p><b>Figure 11-4. Master User Printcap File, Local
5427            Spooling</b></p>
5428<pre class="SCREEN">
5429    # Just information for clients
5430    #  list all of the printers for this server
5431    lp1|lp2|.....
5432      :client:lp=%Q@server1.private:force_localhost
5433    
5434    lp99|....
5435      :client:lp=%Q@server2.private:force_localhost
5436</pre>
5437          </div>
5438
5439          <p>Observe that you have two queues, one per print
5440          server. You use the <tt class="LITERAL">lp=%Q@server</tt>
5441          form of the destination. Note that you will need <b
5442          class="APPLICATION">LPRng</b> version 3.8.0 or later for
5443          this to work.</p>
5444        </div>
5445
5446        <div class="SECT1">
5447          <hr>
5448
5449          <h1 class="SECT1"><a name="AEN1399">11.4. Master Print
5450          Servers, Selection by User</a></h1>
5451
5452          <div class="FIGURE">
5453            <a name="AEN1401"></a>
5454
5455            <p><b>Figure 11-5. Master User Printcap File, No Local
5456            Spooling</b></p>
5457<pre class="SCREEN">
5458    #  list all of the printers for this server
5459    lp1|lp2|.....
5460    OR
5461    lp1|*
5462      :client:lp=%Q@server1.private:force_localhost@
5463      :oh=*.engineering.private
5464    
5465    lp1|lp2|.....
5466    OR
5467    lp1|*
5468      :client:lp=%Q@server2.private:force_localhost@
5469      :oh=*.marketing.private
5470</pre>
5471          </div>
5472
5473          <p>You can use the <tt class="LITERAL">:oh=</tt><i class=
5474          "EMPHASIS">Pattern</i> to select the set of printcap
5475          entries that can be used on a host. The <i class=
5476          "EMPHASIS">Pattern</i> can be IP Address/netmask (<tt
5477          class="LITERAL">10.0.0.0/24</tt> or <tt class=
5478          "LITERAL">10.0.0.0/255.255.255.0</tt>) or a wildcard
5479          match for the DNS resovled host name (<tt class=
5480          "LITERAL">*.eng.private</tt>).</p>
5481        </div>
5482
5483        <div class="SECT1">
5484          <hr>
5485
5486          <h1 class="SECT1"><a name="AEN1411">11.5. The Great Grand
5487          Dad Of All Printcap Files</a></h1>
5488
5489          <div class="FIGURE">
5490            <a name="AEN1413"></a>
5491
5492            <p><b>Figure 11-6. All In One</b></p>
5493<pre class="SCREEN">
5494    #  list all of the printers for this server
5495    lp1|lp2|.....
5496      :client:lp=%Q@server1.private:force_localhost@
5497      :oh=*.engineering.private
5498    lp1|lp2|.....
5499      :client:lp=%Q@server2.private:force_localhost@
5500      :oh=*.marketing.private
5501    lp1:server
5502      :....
5503    lp2:server
5504      :....
5505</pre>
5506          </div>
5507
5508          <p>Add all the printer information in as well. Huge
5509          printcap files. But very easy to manage. But how do you
5510          get them to the user?</p>
5511        </div>
5512
5513        <div class="SECT1">
5514          <hr>
5515
5516          <h1 class="SECT1"><a name="AEN1417">11.6. Using Printcap
5517          Filters and Central Databases</a></h1>
5518
5519          <div class="FIGURE">
5520            <a name="AEN1419"></a>
5521
5522            <p><b>Figure 11-7. Printcap Path Configuration
5523            Information</b></p>
5524<pre class="SCREEN">
5525    /etc/lpd.conf:
5526    
5527    # Purpose: lpd printcap path
5528    #   default lpd_printcap_path= (STRING)
5529    # Purpose: /etc/printcap files
5530    #   default printcap_path= /etc/printcap   (STRING)
5531    printcap_path=|/usr/local/libexec/get_printcap
5532</pre>
5533          </div>
5534
5535          <p>If the <tt class="FILENAME">/etc/lpd.conf</tt> <tt
5536          class="LITERAL">printcap_path</tt> value is a filter,
5537          then the <b class="APPLICATION">LPRng</b> application
5538          will write the name of the requested printer to the <tt
5539          class="LITERAL">STDIN</tt> of the filter program and
5540          expect to read one or more printcap entries from <tt
5541          class="LITERAL">STDOUT</tt>. If the printcap entry
5542          contains a <tt class="LITERAL">:tc</tt> reference, then
5543          this entry will be looked up in turn.</p>
5544
5545          <div class="FIGURE">
5546            <a name="AEN1429"></a>
5547
5548            <p><b>Figure 11-8. Example of Returned Printcap
5549            Value</b></p>
5550<pre class="SCREEN">
5551    Configuration: printcap_path = |/usr/local/bin/get_ldap_pc
5552    
5553    h110: {917} % lpr -Plp
5554    
5555      Printcap access equivalent to Perlish:
5556       $printcap = `echo lp | /usr/local/bin/get_ldap_pc`
5557    
5558    Configuration: lpd_printcap_path = |/usr/local/bin/get_lpd_ldap_pc
5559       lpd server will do:
5560       $printcap = `echo lp | /usr/local/bin/get_lpd_ldap_pc`
5561</pre>
5562          </div>
5563
5564          <p>The exercise of building the necessary <tt class=
5565          "LITERAL">LDAP</tt> database, extracting the information
5566          in a printcap form using the Perl</p>
5567        </div>
5568      </div>
5569
5570      <div class="CHAPTER">
5571        <hr>
5572
5573        <h1><a name="AEN1434">Chapter 12. <b class=
5574        "APPLICATION">LPRngTool</b></a></h1>
5575
5576        <div class="FIGURE">
5577          <a name="AEN1437"></a>
5578
5579          <p><b>Figure 12-1. Starting Screen</b></p>
5580
5581          <div class="MEDIAOBJECT">
5582            <p><img src="x_open.png"></p>
5583          </div>
5584        </div>
5585
5586        <div class="FIGURE">
5587          <a name="AEN1442"></a>
5588
5589          <p><b>Figure 12-2. Printcap Entry Selection</b></p>
5590
5591          <div class="MEDIAOBJECT">
5592            <p><img src="x_printcaps.png"></p>
5593          </div>
5594        </div>
5595
5596        <div class="FIGURE">
5597          <a name="AEN1447"></a>
5598
5599          <p><b>Figure 12-3. Add A Printer</b></p>
5600
5601          <div class="MEDIAOBJECT">
5602            <p><img src="x_add.png"></p>
5603          </div>
5604        </div>
5605
5606        <div class="FIGURE">
5607          <a name="AEN1452"></a>
5608
5609          <p><b>Figure 12-4. Option Specification</b></p>
5610
5611          <div class="MEDIAOBJECT">
5612            <p><img src="x_edit.png"></p>
5613          </div>
5614        </div>
5615
5616        <div class="FIGURE">
5617          <a name="AEN1457"></a>
5618
5619          <p><b>Figure 12-5. Advanced Options</b></p>
5620
5621          <div class="MEDIAOBJECT">
5622            <p><img src="x_advanced.png"></p>
5623          </div>
5624        </div>
5625
5626        <div class="FIGURE">
5627          <a name="AEN1462"></a>
5628
5629          <p><b>Figure 12-6. ifhp Options</b></p>
5630
5631          <div class="MEDIAOBJECT">
5632            <p><img src="x_ifhpfilter.png"></p>
5633          </div>
5634        </div>
5635
5636        <div class="FIGURE">
5637          <a name="AEN1468"></a>
5638
5639          <p><b>Figure 12-7. Saving Printcap Entry</b></p>
5640
5641          <div class="MEDIAOBJECT">
5642            <p><img src="x_write.png"></p>
5643          </div>
5644        </div>
5645
5646        <div class="FIGURE">
5647          <a name="AEN1473"></a>
5648
5649          <p><b>Figure 12-8. Checkpc Results</b></p>
5650
5651          <div class="MEDIAOBJECT">
5652            <p><img src="x_checkpc.png"></p>
5653          </div>
5654        </div>
5655      </div>
5656
5657      <div class="APPENDIX">
5658        <hr>
5659
5660        <h1><a name="SECFEATURES">Appendix A. <b class=
5661        "APPLICATION">LPRng</b></a></h1>
5662
5663        <p>The <b class="APPLICATION">LPRng</b> print spooler
5664        software was developed to be robust, reliable, secure,
5665        scalable, and portable. It has been used since 1988 in
5666        extremely demanding academic printing environments such as
5667        University of Minnesota, MIT, and Rutgers, commercial
5668        companies such as Dow Jones and Abbot Pharmaceuticals, as
5669        well as being distributed with Linux, FreeBSD, and other
5670        systems. Each of these environments has a unique set of
5671        problems, demanding various configuration and
5672        administrative capabilities. For example, the simple single
5673        user system with a single or limited number of printers
5674        requires easy configuration and simple diagnostic
5675        procedures, while the network based printing system
5676        requires highly robust error logging, authentication, and
5677        failover support. <b class="APPLICATION">LPRng</b> provides
5678        a highly flexible configuration system that allows it to
5679        perform optimally in all of these environments.</p>
5680
5681        <p>The <b class="APPLICATION">LPRng</b> software has three
5682        components: the <b class="APPLICATION">lpd</b> print
5683        spooler and the user client applications <b class=
5684        "APPLICATION">lpr</b>, <b class="APPLICATION">lpq</b>, <b
5685        class="APPLICATION">lprm</b>, etc.; the IFHP print filter
5686        (<b class="APPLICATION">ifhp</b>) which is used to convert
5687        jobs into a suitable for a particular printer, and the the
5688        LPRngTool Graphic User Interface (<b class=
5689        "APPLICATION">lprngtool</b>) which provides a simple and
5690        easy to use configuration and monitoring tool for the <b
5691        class="APPLICATION">LPRng</b> print spooler.</p>
5692
5693        <p><b class="APPLICATION">LPRng</b> mimics many of the
5694        features of the <i class="EMPHASIS">vintage</i> or <i
5695        class="EMPHASIS">legacy</i> Berkeley (University of
5696        California - Berkeley) Line Printer (LPR) package found on
5697        Berkeley derivatives of the Unix operating system. <b
5698        class="APPLICATION">LPRng</b> will print a document with
5699        little or no knowledge of the content or special processing
5700        required to print the document on a stand-alone machine or
5701        in a distributed printing environment. New (as compared to
5702        Berkeley LPR) features include: lightweight <b class=
5703        "APPLICATION">lpr</b>, <b class="APPLICATION">lpc</b> and
5704        <b class="APPLICATION">lprm</b> programs, dynamic
5705        redirection of print queues, automatic job holding, highly
5706        verbose diagnostics, load balancing queues; enhanced
5707        security (SUID not required in most environments), and easy
5708        configuration.</p>
5709
5710        <p><b class="APPLICATION">LPRng</b> started life at the
5711        University of Waterloo in 1986 as PLP (Public Line
5712        Printer), a replacement for the original BSD <b class=
5713        "APPLICATION">lpd</b> code. This was a one-shot effort by
5714        the author, Patrick Powell, to develop freely redistributed
5715        code without the restrictions of the BSD/AT&amp;T license
5716        and would allow non-licensed sites to fix and patch
5717        problems. From 1988 to 1992 individuals and groups added
5718        features, hacked, slashed, and modified the PLP code,
5719        coordinated largely by Justin Mason (<tt class=
5720        "EMAIL">&lt;<a href=
5721        "mailto:jmason@iona.ie">jmason@iona.ie</a>&gt;</tt>) who
5722        started the <b class="APPLICATION">LPRng</b> mailing
5723        list.</p>
5724
5725        <p>In 1992 while at San Diego State University Prof. Powell
5726        redesigned and reimplemented the PLP code and named the
5727        result <b class="APPLICATION">LPRng</b>. The goals of the
5728        <b class="APPLICATION">LPRng</b> project were to build a
5729        server system that was as close to user abuse proof as
5730        possible, that would provide services limited only by the
5731        inherent capacities of the support system, RFC1179
5732        compliant, and with extensive debugging capabilities to
5733        allow quick and easy diagnostics of problems.</p>
5734
5735        <p>In 1999 the code base for <b class=
5736        "APPLICATION">LPRng</b> was again reorganized in order to
5737        provide a common method for running on non-UNIX platforms
5738        such as Microsoft Windows NT, Apple Rhapsody, and embedded
5739        systems.</p>
5740
5741        <p>As a side effect of this work, many security problems
5742        that could develop were identified and steps taken to
5743        ensure that they were not present in <b class=
5744        "APPLICATION">LPRng</b>. For example, <b class=
5745        "APPLICATION">LPRng</b> clients such as lpr, lprm, lpc, and
5746        lpq can run as ordinary users programs, the lpd server can
5747        run as a non-root user once a network port has been opened,
5748        and all text formatting operations done by <b class=
5749        "APPLICATION">LPRng</b> use a very restricted and highly
5750        secure version of the <b class="APPLICATION">snprintf</b>
5751        function.</p>
5752
5753        <div class="SECT1">
5754          <hr>
5755
5756          <h1 class="SECT1"><a name="MAILLIST">A.1.
5757          Documentation</a></h1>
5758
5759          <p>The main <b class="APPLICATION">LPRng</b>
5760          documentation is the LPRng-HOWTO, which is available in
5761          several formats. Information about <b class=
5762          "APPLICATION">LPRng</b> and the latest release can be
5763          found on the <b class="APPLICATION">LPRng</b> web page <a
5764          href="http://www.lprng.com/LPRng.html" target=
5765          "_top">http://www.lprng.com/LPRng.html</a></p>
5766
5767          <p>The <b class="APPLICATION">ifhp</b> documentation is
5768          the IFHP-HOWTO, which is available in the <b class=
5769          "APPLICATION">ifhp</b> distribution. Information about <b
5770          class="APPLICATION">ifhp</b> and the latest release can
5771          be found on the <b class="APPLICATION">LPRng</b> web page
5772          <a href="http://www.lprng.com/LPRng.html" target=
5773          "_top">http://www.lprng.com/LPRng.html</a></p>
5774
5775          <p>There is also a mailing list at <a href=
5776          "mailto:lprng-request@lprng.com?subject=subscribe"
5777          target="_top">lprng@lprng.com</a>. To post to the list
5778          you must subscribe by sending send an email to <a href=
5779          "mailto:lprng-request@lprng.com?subject=subscribe"
5780          target="_top">lprng-request@lprng.com</a>, with the
5781          message subject or body containing the word `subscribe'
5782          or `help'.</p>
5783
5784          <p>Several presentations of <b class=
5785          "APPLICATION">LPRng</b> and print spooling software have
5786          been made at the Large Installation System Administrator
5787          (LISA) conferences. The presentation at the LISA 98
5788          conference is in the PowerPoint file <tt class=
5789          "FILENAME">LISA98.ppt</tt> in the <b class=
5790          "APPLICATION">LPRng</b> distribution
5791          documentation.&#13;</p>
5792        </div>
5793
5794        <div class="SECT1">
5795          <hr>
5796
5797          <h1 class="SECT1"><a name="AEN1548">A.2.
5798          Installation</a></h1>
5799
5800          <p>It is recommended that installation be done from the
5801          source distribution, and that the files be put in the <tt
5802          class="FILENAME">/usr/bin</tt>, <tt class=
5803          "FILENAME">/usr/sbin</tt>, and <tt class=
5804          "FILENAME">/etc</tt> directories, as most existing
5805          applications require them there.</p>
5806
5807          <p>Get the source code distribution from the main <b
5808          class="APPLICATION">LPRng</b> site or one of the mirror
5809          sites show in <a href="#LPRNGDIST">Section A.5</a>. The
5810          install using:</p>
5811
5812          <div class="INFORMALEXAMPLE">
5813            <a name="AEN1557"></a>
5814<pre class="SCREEN">
5815    %&gt; gunzip -c LPRng-XXX.tgz | tar xvf -
5816    %&gt; cd LPRng-XXX
5817       <i class=
5818"EMPHASIS">(You might want to read the README and INSTALL files)</i>
5819    %&gt; ./configure --prefix=/usr --sysconfdir=/etc
5820       #if your OS does not support shared libraries, use:
5821       # ./configure --disable-shared --prefix=/usr --sysconfdir=/etc
5822    %&gt; make clean all
5823    %&gt; su
5824    password: xxxxx
5825    #&gt; make install
5826</pre>
5827          </div>
5828        </div>
5829
5830        <div class="SECT1">
5831          <hr>
5832
5833          <h1 class="SECT1"><a name="AEN1560">A.3. License</a></h1>
5834
5835          <p>The <b class="APPLICATION">LPRng</b> Print Spooler and
5836          the ifhp Print Filter software are distributed under the
5837          <a href="license.txt" target="_top">GNU Public License
5838          (GPL) and the Artistic License</a>. Users can choose to
5839          redistribute or use the software under a license that is
5840          appropriate for their purpose. Other licenses and
5841          distribution agreements are available by contacting <a
5842          href="http://www.astart.com" target="_top">AStArt
5843          Technologies</a> for information.</p>
5844        </div>
5845
5846        <div class="SECT1">
5847          <hr>
5848
5849          <h1 class="SECT1"><a name="AEN1566">A.4. Commercial
5850          Support</a></h1>
5851
5852          <p><a href="http://www.astart.com" target="_top">AStArt
5853          Technologies</a> provides commercial support and
5854          enhancements for the <b class="APPLICATION">LPRng</b> and
5855          other network software. AStArt provides network and
5856          system consulting services for UNIX and NT systems, as
5857          well as real time and network software.</p>
5858        </div>
5859
5860        <div class="SECT1">
5861          <hr>
5862
5863          <h1 class="SECT1"><a name="LPRNGDIST">A.5. Web Site, FTP
5864          Site, and Mirrors</a></h1>
5865
5866          <p>Web Page: <a href="http://www.lprng.com" target=
5867          "_top">http://www.lprng.com</a></p>
5868
5869          <p>Main FTP Site:</p>
5870
5871          <table border="0">
5872            <tbody>
5873              <tr>
5874                <td><a href="ftp://ftp.lprng.com/pub/LPRng" target=
5875                "_top">ftp://ftp.lprng.com/pub/LPRng</a> (US)</td>
5876              </tr>
5877            </tbody>
5878          </table>
5879          <br>
5880          <br>
5881
5882          <p>Mirrors:</p>
5883
5884          <table border="0">
5885            <tbody>
5886              <tr>
5887                <td><a href=
5888                "ftp://ftp.cs.columbia.edu/pub/archives/pkg/LPRng"
5889                target=
5890                "_top">ftp://ftp.cs.columbia.edu/pub/archives/pkg/LPRng</a>
5891                (US)</td>
5892              </tr>
5893
5894              <tr>
5895                <td><a href=
5896                "ftp://ftp.cise.ufl.edu/pub/mirrors/LPRng" target=
5897                "_top">ftp://ftp.cise.ufl.edu/pub/mirrors/LPRng</a>
5898                (US)</td>
5899              </tr>
5900
5901              <tr>
5902                <td><a href="ftp://ftp.cs.umn.edu/pub/LPRng"
5903                target="_top">ftp://ftp.cs.umn.edu/pub/LPRng</a>
5904                (US)</td>
5905              </tr>
5906
5907              <tr>
5908                <td><a href=
5909                "ftp://uiarchive.uiuc.edu/pub/packages/LPRng"
5910                target=
5911                "_top">ftp://uiarchive.uiuc.edu/pub/packages/LPRng</a>
5912                (US)</td>
5913              </tr>
5914
5915              <tr>
5916                <td><a href=
5917                "ftp://ftp.sage-au.org.au/pub/printing/spooler/lprng/"
5918                 target=
5919                "_top">ftp://ftp.sage-au.org.au/pub/printing/spooler/lprng/</a>
5920                (AU)</td>
5921              </tr>
5922
5923              <tr>
5924                <td><a href="ftp://mirror.aarnet.edu.au/pub/LPRng/"
5925                target=
5926                "_top">ftp://mirror.aarnet.edu.au/pub/LPRng/</a>
5927                (AU/NZ)</td>
5928              </tr>
5929
5930              <tr>
5931                <td><a href=
5932                "http://mirror.aarnet.edu.au/pub/LPRng/" target=
5933                "_top">http://mirror.aarnet.edu.au/pub/LPRng/</a>
5934                (AU/NZ)</td>
5935              </tr>
5936
5937              <tr>
5938                <td><a href=
5939                "ftp://sunsite.ualberta.ca/pub/Mirror/LPRng"
5940                target=
5941                "_top">ftp://sunsite.ualberta.ca/pub/Mirror/LPRng</a>
5942                (CA)</td>
5943              </tr>
5944
5945              <tr>
5946                <td><a href=
5947                "ftp://ftp.informatik.uni-hamburg.de/pub/os/unix/utils/LPRng"
5948                 target=
5949                "_top">ftp://ftp.informatik.uni-hamburg.de/pub/os/unix/utils/LPRng</a>
5950                (DE)</td>
5951              </tr>
5952
5953              <tr>
5954                <td><a href=
5955                "ftp://ftp.uni-paderborn.de/pub/unix/printer/LPRng"
5956                target=
5957                "_top">ftp://ftp.uni-paderborn.de/pub/unix/printer/LPRng</a>
5958                (DE)</td>
5959              </tr>
5960
5961              <tr>
5962                <td><a href="ftp://ftp.mono.org/pub/LPRng" target=
5963                "_top">ftp://ftp.mono.org/pub/LPRng</a> (UK)</td>
5964              </tr>
5965
5966              <tr>
5967                <td><a href="ftp://ftp.iona.com/pub/plp/LPRng"
5968                target="_top">ftp://ftp.iona.com/pub/plp/LPRng</a>
5969                (IE)</td>
5970              </tr>
5971
5972              <tr>
5973                <td><a href=
5974                "ftp://uabgate.uab.ericsson.se/pub/unix/LPRng"
5975                target=
5976                "_top">ftp://uabgate.uab.ericsson.se/pub/unix/LPRng</a>
5977                (SE)</td>
5978              </tr>
5979            </tbody>
5980          </table>
5981          <br>
5982          <br>
5983        </div>
5984
5985        <div class="SECT1">
5986          <hr>
5987
5988          <h1 class="SECT1"><a name="AEN1607">A.6. Mailing
5989          List</a></h1>
5990
5991          <p>To join the <b class="APPLICATION">LPRng</b> mailing
5992          list, please send mail to <a href=
5993          "mailto: lprng-request@lprng.com" target=
5994          "_top">lprng-request@lprng.com</a> with the word
5995          'subscribe' in the BODY.</p>
5996
5997          <p>The <b class="APPLICATION">LPRng</b> mailing list is
5998          archived on <a href="http://www.findmail.com/list/lprng"
5999          target="_top">http://www.findmail.com/list/lprng</a></p>
6000        </div>
6001
6002        <div class="SECT1">
6003          <hr>
6004
6005          <h1 class="SECT1"><a name="FAQREF">A.7. PGP Public
6006          Key</a></h1>
6007
6008          <p>The <b class="APPLICATION">LPRng</b> distributions
6009          have an MD5 checksum calculated, which is then signed
6010          with a PGP public key. Here is the key for validating the
6011          checksums:</p>
6012
6013          <div class="INFORMALEXAMPLE">
6014            <a name="AEN1619"></a>
6015<pre class="SCREEN">
6016    Type Bits/KeyID    Date       User ID
6017    pub  1024/00D95C9D 1997/01/31 Patrick A. Powell \
6018       &lt;papowell@lprng.com&gt;
6019    
6020    -----BEGIN PGP PUBLIC KEY BLOCK-----
6021    Version: 2.6.3i
6022    
6023    mQCNAzLygTQAAAEEANBW5fPYjN3wSAnP9xWOUc3CvsMUxjip0cN2sY5qrdoJyIhn
6024    qbAspBopR+tGQfyp5T7C21yfWRRnfXmoJ3FVtgToAsJUYmzoSFY08eDx+rmSqCLe
6025    rdJjX8aG8jVXpGipEo9U4QsUK+OKzx3/y/OaK4cizoWqKvy1l4lEzDsA2VydAAUT
6026    tCdQYXRyaWNrIEEuIFBvd2VsbCA8cGFwb3dlbGxAYXN0YXJ0LmNvbT6JAJUDBRA0
6027    XonoiUTMOwDZXJ0BAQ2cBAC7zU9Fn3sC3x0USJ+3vjhg/qA+Gjb5Fi1dJd4solc4
6028    vJvtf0UL/1/rGipbR+A0XHpHzJUMP9ZfJzKZjaK/d0ZBNlS3i+JnypypeQiAqo9t
6029    FV0OyUCwDfWybgAORuAa2V6UJnAhvj/7TpxMmCApolaIb4yFyKunHa8aBxN+17Ro
6030    rrQlUGF0cmljayBBLiBQb3dlbGwgPHBhcG93ZWxsQHNkc3UuZWR1PokAlQMFEDLy
6031    gTSJRMw7ANlcnQEBYBYD/0zTeoiDNnI+NjaIei6+6z6oakqO70qFVx0FG3aP3kRH
6032    WlDhdtFaAuaMRh+RItHfFfcHhw5K7jiJdgKiTgGfj5Vt3OdHYkeeh/sddqgf9YnS
6033    tpj0u5NfrotPTUw39n6YTgS5/aW0PQfO9dx7jVUcGeod1TGXTe9mIhDMwDJI4J14
6034    =3Zbp
6035    -----END PGP PUBLIC KEY BLOCK-----
6036</pre>
6037          </div>
6038          <br>
6039          <br>
6040        </div>
6041      </div>
6042
6043      <div class="APPENDIX">
6044        <hr>
6045
6046        <h1><a name="AEN1621">Appendix B. References and
6047        Standards</a></h1>
6048
6049        <p>The following references and standards have been used in
6050        the development of the <b class="APPLICATION">LPRng</b>
6051        software.</p>
6052
6053        <div class="SECT1">
6054          <hr>
6055
6056          <h1 class="SECT1"><a name="AEN1625">B.1. RFCs</a></h1>
6057
6058          <p>During the early development of the Internet
6059          developers did not want to go through the laborious
6060          process of developing formal standards and applying to a
6061          standards body such as the EIA, IEEE, or ISO. Instead,
6062          they called the standards documents they developed [<span
6063          class="CITATION">Requests for Comments</span>]. These
6064          soon became <i class="EMPHASIS">de facto</i> standards,
6065          and with the formal acceptance of the TCP/IP protocol as
6066          a network standard, <i class="EMPHASIS">de jure</i> as
6067          well.</p>
6068
6069          <p>You can get copies of the RFCs from literally hundreds
6070          of network sites, including <a href="http://www.isi.edu"
6071          target="_top">http://www.isi.edu</a>, <a href=
6072          "http://www.faqs.org/rfcs" target=
6073          "_top">http://www.faqs.org/rfcs</a>, <a href=
6074          "ftp://NIS.NSF.NET" target="_top">NIS.NSF.NET</a>, <a
6075          href="ftp://RFC.JVNC.NET" target="_top">RFC.JVNC.NET</a>,
6076          or <a href="ftp://FTP.ISI.EDU" target=
6077          "_top">FTP.ISI.EDU</a>.</p>
6078
6079          <p>The [<span class="CITATION">RFC1179 - Line Printer
6080          Daemon Protocol</span>] describes the protocol used to
6081          transfer jobs from client program to print server. See <a
6082          href="#RFC1179REF">RFC1179</a> for more a discussion of
6083          this protocol and more details about the RFC. The <a
6084          href="rfc1179.txt" target="_top">rfc1179.txt</a> file is
6085          included in the <b class="APPLICATION">LPRng</b>
6086          distribution documentation.</p>
6087        </div>
6088
6089        <div class="SECT1">
6090          <hr>
6091
6092          <h1 class="SECT1"><a name="POSTSCRIPT">B.2.
6093          PostScript</a></h1>
6094
6095          <p>PostScript is one of the <i class="EMPHASIS">de
6096          facto</i> standards for print jobs. The Adobe Corporation
6097          (<a href="http://www.adobe.com" target=
6098          "_top">http://www.adobe.com</a>) provides an excellent
6099          set of references for the PostScript language. They have
6100          made many of these available for downloading from their
6101          web sites or have published them in book form.</p>
6102
6103          <p>The [<span class="CITATION">PostScript Language
6104          Reference Manual</span>] contains a great deal of
6105          technical information about the PostScript Language, and
6106          is the language reference manual.</p>
6107
6108          <p>The [<span class="CITATION">PostScript Language
6109          Tutorial and Cookbook</span>] is a very nice and easy to
6110          read introduction to PostScript programming, and has some
6111          very useful utilities. Combined with <b class=
6112          "APPLICATION">GhostScript</b> and the <b class=
6113          "APPLICATION">gv</b> display program you can very easily
6114          learn to write your own small PostScript programs, and
6115          more importantly, can learn to understand the contents of
6116          PostScript files.</p>
6117
6118          <p>The [<span class="CITATION">PostScript Language
6119          Program Design</span>] is the companion to the [<span
6120          class="CITATION">PostScript Language Tutorial and
6121          Cookbook</span>], and has more complex examples of
6122          PostScript programs. More importantly, it also
6123          introduces, although without explanation, the PostScript
6124          Document Structuring Conventions described in Appendix G
6125          of the The [<span class="CITATION">PostScript Language
6126          Reference Manual</span>]. This alone makes it useful.</p>
6127        </div>
6128
6129        <div class="SECT1">
6130          <hr>
6131
6132          <h1 class="SECT1"><a name="PCL">B.3. HP PCL 5</a></h1>
6133
6134          <p>The Hewlett-Packard (HP) PCL Printer Language is the
6135          second de-facto standard for print jobs. Currently,
6136          Hewlett-Packard makes documentation for PCL available
6137          through their [<span class="CITATION">Developer
6138          Program</span>]. You will need to register and then
6139          search their site for the [<span class="CITATION">PCL 5
6140          Printer Language Reference Manual</span>].</p>
6141        </div>
6142
6143        <div class="SECT1">
6144          <hr>
6145
6146          <h1 class="SECT1"><a name="PJL">B.4. HP PJL</a></h1>
6147
6148          <p>The Hewlett-Packard (HP) Printer Job Language is used
6149          to control various features of HP printers. The [<span
6150          class="CITATION">Printer Job Language Reference
6151          Manual</span>] is also available from Hewlett-Packard (<a
6152          href="http://www.hp.com" target=
6153          "_top">http://www.hp.com</a>) through their [<span class=
6154          "CITATION">Developer Program</span>].</p>
6155        </div>
6156
6157        <div class="SECT1">
6158          <hr>
6159
6160          <h1 class="SECT1"><a name="AEN1668">B.5. PDF</a></h1>
6161
6162          <p>The Portable Document Format (<tt class=
6163          "LITERAL">pdf</tt>) was developed by Adobe to be a more
6164          useful method of distributing documentation for view by
6165          online systems and software. The [<span class=
6166          "CITATION">Portable Document Format Reference
6167          Manual</span>] is available from Adobe (<a href=
6168          "http://www.adobe.com" target=
6169          "_top">http://www.adobe.com</a>). While <tt class=
6170          "LITERAL">pdf</tt> is not used directly as a print job
6171          language, it is one of the more common formats for files
6172          that need to be printed. It can be converted to
6173          PostScript by most <tt class="LITERAL">pdf</tt> viewers
6174          such as GhostScript and Adobe Acrobat.</p>
6175        </div>
6176      </div>
6177
6178      <div class="APPENDIX">
6179        <hr>
6180
6181        <h1><a name="RFC1179REF">Appendix C. RFC 1179 - Line
6182        Printer Daemon Protocol</a></h1>
6183
6184        <p>RFC1179 can be obtained from the <b class=
6185        "APPLICATION">LPRng</b> distribution, in the
6186        LPRng_DOC/rfc1179 directory, or from one of many sites
6187        which mirror the RFCs.</p>
6188
6189        <p>This RFC is an <i class="EMPHASIS">informational</i>
6190        RFC, which means that the information in it is meant as a
6191        guide to users, and not as a fixed standard. In addition,
6192        the RFC tried to document the behavior of the BSD <b class=
6193        "APPLICATION">lpd</b> print server, and left out many
6194        details dealing with error recover, error messages,
6195        extensions to the protocol, etc.</p>
6196
6197        <p>In this section, I will try to explain what RFC1179
6198        specifies as a protocol, and many of the problems
6199        encountered in trying to use it.</p>
6200
6201        <div class="SECT1">
6202          <hr>
6203
6204          <h1 class="SECT1"><a name="LPDPORT">C.1. Ports and
6205          Connections</a></h1>
6206
6207          <p>Options used:</p>
6208
6209          <ul>
6210            <li>
6211              <p><tt class="LITERAL">lpd_port=</tt><i class=
6212              "EMPHASIS">Port for <b class="APPLICATION">lpd</b> to
6213              accept connection</i></p>
6214            </li>
6215
6216            <li>
6217              <p><tt class="LITERAL">originate_port=</tt><i class=
6218              "EMPHASIS">Ports to originate connections on</i></p>
6219            </li>
6220
6221            <li>
6222              <p><tt class="LITERAL">reuse_addr</tt> FLAG <i class=
6223              "EMPHASIS">Set SO_REUSEADDR flag on
6224              connection</i></p>
6225            </li>
6226
6227            <li>
6228              <p><tt class="LITERAL">retry_econnrefused</tt> FLAG
6229              <i class="EMPHASIS">Retry on connect ECONNREFUSED
6230              error</i></p>
6231            </li>
6232
6233            <li>
6234              <p><tt class="LITERAL">retry_nolink</tt> FLAG <i
6235              class="EMPHASIS">Retry on device open or connection
6236              ffailure</i></p>
6237            </li>
6238
6239            <li>
6240              <p><tt class="LITERAL">socket_linger=</tt><i class=
6241              "EMPHASIS">socket linger timeout</i></p>
6242            </li>
6243          </ul>
6244          <br>
6245          <br>
6246
6247          <p>RFC1179 requires that the <b class=
6248          "APPLICATION">lpd</b> server listen for TCP/IP
6249          connections on port 515. This port is registered with the
6250          Internet Naming Authority, and the <tt class=
6251          "FILENAME">/etc/services</tt> file or TCP/IP services
6252          database usually has an entry:</p>
6253
6254          <div class="INFORMALEXAMPLE">
6255            <a name="AEN1716"></a>
6256<pre class="SCREEN">
6257    printer     515/tcp     spooler     # line printer spooler
6258</pre>
6259          </div>
6260          <br>
6261          <br>
6262
6263          <p>RFC1179 explicitly states that all connections to port
6264          515 must originate from ports 721-731. The reason for
6265          this restriction is due to the UNIX concept of <i class=
6266          "EMPHASIS">reserved</i> and <i class=
6267          "EMPHASIS">privileged</i> ports. By convention, ports in
6268          the range 1-1023 can only <i class="EMPHASIS">bound</i>
6269          by processes whose Effective User ID (EUID) is 0 (root).
6270          This, ordinary users could not originate a connection
6271          from the reserved or privileged port range.</p>
6272
6273          <p>In a UNIX environment, this means that the user
6274          programs <b class="APPLICATION">lpr</b>, <b class=
6275          "APPLICATION">lpq</b>, <b class="APPLICATION">lprm</b>,
6276          and <b class="APPLICATION">lpc</b> would have to be
6277          SETUID root.</p>
6278
6279          <p>As experience has shown, for security purposes, the
6280          fewer programs that need to have privileged status, the
6281          better. <b class="APPLICATION">LPRng</b> uses the <tt
6282          class="LITERAL">lpd_port=printer</tt> configuration
6283          option to set the actual port to be use. By default, this
6284          is port 515, but can be set to other values.</p>
6285
6286          <p>The restriction of originating ports to 721-731 causes
6287          another set of problems. Part of the TCP/IP protocol is
6288          concerned with avoiding communications problems resulting
6289          from the arrival of old or <i class="EMPHASIS">stale</i>
6290          packets. When a connection between <tt class=
6291          "LITERAL">sourcehost, sourceport</tt> and <tt class=
6292          "LITERAL">desthost, destport</tt> is made, a set of
6293          sequence numbers is established and used for sending and
6294          acknowledgement of data. When the connection terminates,
6295          the TCP/IP protocol restricts the establishment of a new
6296          connection between <tt class="LITERAL">sourcehost,
6297          sourceport</tt> and <tt class="LITERAL">desthost,
6298          destport</tt> for a period long enough for all <i class=
6299          "EMPHASIS">stale</i> packets to be removed from the
6300          system. This is approximately 10 minutes long.</p>
6301
6302          <p>In order to simplify assignments of ports, timing out
6303          connections, and other matters, many TCP/IP packages do
6304          keep track of explicit connections <i class=
6305          "EMPHASIS">originating</i> from a port, but simply
6306          prevent the port from being reused for either origination
6307          or reception of a connection. They do, however, keep
6308          track of the active connections <i class=
6309          "EMPHASIS">to</i> a port, and perform timeouts on these.
6310          This is usually much simpler to implement, as it can be
6311          done with a list attached to the port.</p>
6312
6313          <p>This implementation method creates some problems when
6314          a large number of connections must be originated from a
6315          relatively small number of port numbers. Observe what
6316          happens when host 1 tries to send a large number of jobs
6317          to a server 2. The following connections are established
6318          and terminated: <tt class="LITERAL">host 1, port 721</tt>
6319          and <tt class="LITERAL">host 2, port 515</tt> <tt class=
6320          "LITERAL">host 1, port 722</tt> and <tt class=
6321          "LITERAL">host 2, port 515</tt> <tt class="LITERAL">host
6322          1, port 723</tt> and <tt class="LITERAL">host 2, port
6323          515</tt> <tt class="LITERAL">host 1, port 724</tt> and
6324          <tt class="LITERAL">host 2, port 515</tt> <tt class=
6325          "LITERAL">host 1, port 725</tt> and <tt class=
6326          "LITERAL">host 2, port 515</tt> <tt class="LITERAL">host
6327          1, port 726</tt> and <tt class="LITERAL">host 2, port
6328          515</tt> <tt class="LITERAL">host 1, port 727</tt> and
6329          <tt class="LITERAL">host 2, port 515</tt> <tt class=
6330          "LITERAL">host 1, port 728</tt> and <tt class=
6331          "LITERAL">host 2, port 515</tt> <tt class="LITERAL">host
6332          1, port 729</tt> and <tt class="LITERAL">host 2, port
6333          515</tt> <tt class="LITERAL">host 1, port 730</tt> and
6334          <tt class="LITERAL">host 2, port 515</tt> <tt class=
6335          "LITERAL">host 1, port 731</tt> and <tt class=
6336          "LITERAL">host 2, port 515</tt></p>
6337
6338          <p>Now according to the RFC1179 rules and the TCP/IP
6339          protocol, we will have to wait until one of these
6340          connections terminates before we can make another. On the
6341          originating system, if the TCP/IP implementation does
6342          timeouts on the originating port, we will have to wait
6343          for the timeout to elapse before we can make a new
6344          connection. Unfortunately, there is no way to find out
6345          what the status of the port is, so we will have to try
6346          them each in turn until we get a successful
6347          connection.</p>
6348
6349          <p>The <b class="APPLICATION">LPRng</b> code has tried to
6350          provide several methods to deal with these problems.
6351          Firstly, the <tt class="LITERAL">originate_port=512
6352          1023</tt> option specifies the range of ports used to
6353          originate connections when the software is running either
6354          as ROOT or SETUID root. By strict RFC1179 rules, this
6355          should be <tt class="LITERAL">originate_port=721
6356          731</tt>, but it turns out that most BSD <b class=
6357          "APPLICATION">lpd</b> based implementations only check
6358          for a <i class="EMPHASIS">reserved</i> originating port.
6359          By using 512 ports we get a greatly reduced rate of
6360          errors due to lack of ports due to pending timeouts.</p>
6361
6362          <p>However, on some systems which are acting as servers
6363          for a large number of printers even increasing this port
6364          range is insufficient, and steps need to be taken use the
6365          originating port numbers more efficiently. The Berkeley
6366          TCP/IP implementation <tt class=
6367          "FUNCTION">getsockopt()</tt> and <tt class=
6368          "FUNCTION">setsockopt()</tt> allows the user to
6369          manipulate some of the underlying timeouts and options of
6370          the TCP/IP network. When a TCP/IP connection is
6371          established, the <tt class="FUNCTION">setsockopt()</tt>
6372          facility can be used to set the <tt class=
6373          "LITERAL">SO_REUSEADDR</tt> flag on the connection. This
6374          flag effectively sets the timeout value on the ports and
6375          connections to 0, allowing immediate reuse of the ports.
6376          When done on an originating end of a connection, this
6377          will allow the originating port number to be reused
6378          immediately.</p>
6379
6380          <p>It would appear that by setting <tt class=
6381          "LITERAL">SO_REUSEADDR</tt> on the originating end that
6382          we have solved our problems. However, unless the
6383          destination end of the connection sets its <tt class=
6384          "LITERAL">SO_REUSEADDR</tt> flag on the connection, it
6385          will still do a timeout. Thus when we try to make a
6386          connection from a port that was active within a short
6387          period of time to the same host, then it will reject the
6388          connection until the timeout is over.</p>
6389
6390          <p>The <tt class="LITERAL">reuse_addr</tt> flag (default
6391          off) forces the <b class="APPLICATION">LPRng</b> software
6392          to set the <tt class="LITERAL">SO_REUSEADDR</tt> flag on
6393          originating connections. As indicated, this will allow
6394          ports to be reused immediately for outgoing connections,
6395          rather than waiting for a timeout.</p>
6396
6397          <p>While the <tt class="LITERAL">reuse_addr</tt> flag
6398          usually allows us to reuse ports, there is still the
6399          problem of dealing with connections failing due to the
6400          remote site rejecting the connection due to a pending
6401          timeout from a previous connection. A careful study of
6402          the original BSD TCP/IP network code and of some others
6403          indicates that when a connection fails due to a pending
6404          timeout, an ECONNREFUSED error code is returned to a <tt
6405          class="FUNCTION">connect()</tt> system call. If this
6406          happens and we suspect that the remote site is rejecting
6407          the connection due to a timeout problem, then we should
6408          retry making the connection but from a new port, and
6409          continue retrying until all possible ports are used.</p>
6410
6411          <p>The <tt class="LITERAL">retry_econnrefused</tt>
6412          (default on) flag is used to specify that we retry
6413          connections in this manner. When this is set, a <tt
6414          class="LITERAL">connection refused</tt> error causes the
6415          connection to be retried using a new port. This will be
6416          repeated until all available ports have been tried.</p>
6417
6418          <p>When printing a job and the <b class=
6419          "APPLICATION">lpd</b> server connection to a remote site
6420          or device open fails, the <tt class=
6421          "LITERAL">retry_nolink</tt> (default on) will cause the
6422          attempt to be retried indefinitely. The combination of
6423          <tt class="LITERAL">retry_econnrefused</tt> and <tt
6424          class="LITERAL">retry_nolink</tt> will provide robust
6425          connection attempts to remote systems.</p>
6426
6427          <p>While the above problems cause difficulties when
6428          making connections, there are also problems when
6429          terminating connections. After closing a socket, the
6430          TCP/IP software will try to flush any pending data to the
6431          destination. Unfortunately, on some systems it will only
6432          do this while the process is active. This has caused
6433          problems on systems which terminate a process it has
6434          received an abnormal (signal caused) termination.</p>
6435
6436          <p>The <tt class="FUNCTION">setsockopt()</tt> SO_LINGER
6437          option allows the user to specify that when a socket is
6438          closed normally, that the process should block until
6439          pending data is flushed or for the <tt class=
6440          "LITERAL">socket_linger</tt> period. If <tt class=
6441          "LITERAL">socket_linger</tt> is 0, then no SO_LINGER
6442          operation is done.</p>
6443
6444          <p>In summary, if you experience problems with connection
6445          failures due to port exhaustion, first try setting the
6446          <tt class="LITERAL">reuse_port</tt> flag, and you should
6447          see a reduction. Check to ensure that the <tt class=
6448          "LITERAL">retry_econnrefused</tt> and <tt class=
6449          "LITERAL">retry_nolink</tt> flags are set, and the error
6450          code in the log and status files. If the failures
6451          continue, then the problem is caused by the remote end
6452          having timeout limitations and there is little you can do
6453          except to set a very long <tt class=
6454          "LITERAL">connect_retry</tt> interval, say <tt class=
6455          "LITERAL">connect_retry=120</tt> (2 minutes).</p>
6456        </div>
6457
6458        <div class="SECT1">
6459          <hr>
6460
6461          <h1 class="SECT1"><a name="REMOTESUPPORT">C.2. Protocol
6462          Requests and Replies</a></h1>
6463
6464          <p>Options used:</p>
6465
6466          <ul>
6467            <li>
6468              <p><tt class="LITERAL">remote_support=</tt><i class=
6469              "EMPHASIS">Remote operations supported</i></p>
6470            </li>
6471          </ul>
6472          <br>
6473          <br>
6474
6475          <p>After a connection has been established, a request can
6476          be sent to the <b class="APPLICATION">lpd</b> server. The
6477          request consists of a single octet indicating the request
6478          type, followed by the printer (or print queue) name,
6479          followed by a set of options for the request, followed by
6480          a LF (line feed) character.</p>
6481
6482          <div class="TABLE">
6483            <a name="RF1179COMMANDS"></a>
6484
6485            <p><b>Table C-1. RFC1179 Commands</b></p>
6486
6487            <table border="1" class="CALSTABLE">
6488              <thead>
6489                <tr>
6490                  <th align="LEFT" valign="TOP">NNN</th>
6491
6492                  <th align="LEFT" valign="TOP">RFC1179</th>
6493
6494                  <th align="LEFT" valign="TOP">Operation</th>
6495
6496                  <th align="LEFT" valign="TOP">program</th>
6497                </tr>
6498              </thead>
6499
6500              <tbody>
6501                <tr>
6502                  <td align="LEFT" valign="TOP">1</td>
6503
6504                  <td align="LEFT" valign="TOP">yes</td>
6505
6506                  <td align="LEFT" valign="TOP">start print</td>
6507
6508                  <td align="LEFT" valign="TOP"><b class=
6509                  "APPLICATION">lpc</b></td>
6510                </tr>
6511
6512                <tr>
6513                  <td align="LEFT" valign="TOP">2</td>
6514
6515                  <td align="LEFT" valign="TOP">yes</td>
6516
6517                  <td align="LEFT" valign="TOP">transfer a printer
6518                  job</td>
6519
6520                  <td align="LEFT" valign="TOP"><b class=
6521                  "APPLICATION">lpr</b></td>
6522                </tr>
6523
6524                <tr>
6525                  <td align="LEFT" valign="TOP">3</td>
6526
6527                  <td align="LEFT" valign="TOP">yes</td>
6528
6529                  <td align="LEFT" valign="TOP">print short form of
6530                  queue status</td>
6531
6532                  <td align="LEFT" valign="TOP"><b class=
6533                  "APPLICATION">lpr</b></td>
6534                </tr>
6535
6536                <tr>
6537                  <td align="LEFT" valign="TOP">4</td>
6538
6539                  <td align="LEFT" valign="TOP">yes</td>
6540
6541                  <td align="LEFT" valign="TOP">print long form of
6542                  queue status</td>
6543
6544                  <td align="LEFT" valign="TOP"><b class=
6545                  "APPLICATION">lpr</b></td>
6546                </tr>
6547
6548                <tr>
6549                  <td align="LEFT" valign="TOP">5</td>
6550
6551                  <td align="LEFT" valign="TOP">yes</td>
6552
6553                  <td align="LEFT" valign="TOP">remove jobs</td>
6554
6555                  <td align="LEFT" valign="TOP"><b class=
6556                  "APPLICATION">lprm</b></td>
6557                </tr>
6558
6559                <tr>
6560                  <td align="LEFT" valign="TOP">6</td>
6561
6562                  <td align="LEFT" valign="TOP"><b class=
6563                  "APPLICATION">LPRng</b></td>
6564
6565                  <td align="LEFT" valign="TOP">do control
6566                  operation</td>
6567
6568                  <td align="LEFT" valign="TOP"><b class=
6569                  "APPLICATION">lpc</b></td>
6570                </tr>
6571
6572                <tr>
6573                  <td align="LEFT" valign="TOP">7</td>
6574
6575                  <td align="LEFT" valign="TOP"><b class=
6576                  "APPLICATION">LPRng</b></td>
6577
6578                  <td align="LEFT" valign="TOP">transfer a block
6579                  format print job</td>
6580
6581                  <td align="LEFT" valign="TOP"><b class=
6582                  "APPLICATION">lpr</b></td>
6583                </tr>
6584
6585                <tr>
6586                  <td align="LEFT" valign="TOP">8</td>
6587
6588                  <td align="LEFT" valign="TOP"><b class=
6589                  "APPLICATION">LPRng</b></td>
6590
6591                  <td align="LEFT" valign="TOP">secure command
6592                  transfer</td>
6593
6594                  <td align="LEFT" valign="TOP"><b class=
6595                  "APPLICATION">lpc</b></td>
6596                </tr>
6597
6598                <tr>
6599                  <td align="LEFT" valign="TOP">9</td>
6600
6601                  <td align="LEFT" valign="TOP"><b class=
6602                  "APPLICATION">LPRng</b></td>
6603
6604                  <td align="LEFT" valign="TOP">verbose status
6605                  information</td>
6606
6607                  <td align="LEFT" valign="TOP"><b class=
6608                  "APPLICATION">lpr</b></td>
6609                </tr>
6610              </tbody>
6611            </table>
6612          </div>
6613
6614          <p>After the request has been sent, then a reply will be
6615          returned. In general the reply has the following
6616          form:</p>
6617
6618          <div class="INFORMALEXAMPLE">
6619            <a name="AEN1883"></a>
6620<pre class="SCREEN">
6621    \000\n    Success
6622    \NNN\n    Failure (NNN is error code)
6623    text\n    Text or status information
6624</pre>
6625          </div>
6626          <br>
6627          <br>
6628
6629          <p>As can be seen, this protocol is extremely simple, but
6630          there are a set of problems due to the loosely written
6631          language of RFC1179.</p>
6632
6633          <ol type="1">
6634            <li>
6635              <p>Firstly, while RFC1179 sets limits on the lengths
6636              of commands, it does not strictly set limits on the
6637              characters set used in the commands. This can result
6638              in problems when trying to print status information,
6639              headers on banners, and other details.</p>
6640            </li>
6641
6642            <li>
6643              <p>The original RFC1179 protocol did not provide any
6644              way to do remote control of queues or <b class=
6645              "APPLICATION">lpd</b> servers. This has been added to
6646              the protocol. As a side effect, if you try to use <b
6647              class="APPLICATION">lpc</b> to control a non-<b
6648              class="APPLICATION">LPRng</b> printer, it will not
6649              work.</p>
6650            </li>
6651
6652            <li>
6653              <p>You can specify that a network printer is non-<b
6654              class="APPLICATION">LPRng</b> by using the <tt class=
6655              "LITERAL">remote_support=RQVMC</tt> option and
6656              specify the operations supported by the printer. The
6657              letters R, Q, M, and C stand for <b class=
6658              "APPLICATION">lpr</b>, <b class=
6659              "APPLICATION">lpq</b>, <b class=
6660              "APPLICATION">lprm</b>, and <b class=
6661              "APPLICATION">lpc</b> operations respectively, and
6662              indicate that these are supported. If <tt class=
6663              "LITERAL">remote_support</tt> does not allow a
6664              particular operation, then the <b class=
6665              "APPLICATION">LPRng</b> software will not send a
6666              corresponding request to the printer. For example,
6667              <tt class="LITERAL">remote_support=R</tt> would
6668              restrict operations to spooling jobs only, and the <b
6669              class="APPLICATION">LPRng</b> software would not
6670              query the printer for status.</p>
6671            </li>
6672          </ol>
6673          <br>
6674          <br>
6675        </div>
6676
6677        <div class="SECT1">
6678          <hr>
6679
6680          <h1 class="SECT1"><a name="JOBTRANSFER">C.3. Job
6681          Transfer</a></h1>
6682
6683          <p>Options used:</p>
6684
6685          <ul>
6686            <li>
6687              <p><tt class="LITERAL">longnumber</tt> FLAG <i class=
6688              "EMPHASIS">Long job number (6 digits)</i></p>
6689            </li>
6690
6691            <li>
6692              <p><tt class="LITERAL">send_data_first</tt> FLAG <i
6693              class="EMPHASIS">Send data files first</i></p>
6694            </li>
6695
6696            <li>
6697              <p><tt class="LITERAL">use_shorthost</tt><i class=
6698              "EMPHASIS">Use short hostname</i></p>
6699            </li>
6700          </ul>
6701          <br>
6702          <br>
6703
6704          <p>A job transfer operation starts with a job transfer
6705          request, followed by several file transfer operations. At
6706          the end of the file transfers, the connection should be
6707          closed.</p>
6708
6709          <p>A file transfer request has the form:</p>
6710
6711          <div class="INFORMALTABLE">
6712            <a name="AEN1924"></a>
6713
6714            <table border="1" class="CALSTABLE">
6715              <thead>
6716                <tr>
6717                  <th align="LEFT" valign="TOP">Command</th>
6718
6719                  <th align="LEFT" valign="TOP">Purpose</th>
6720                </tr>
6721              </thead>
6722
6723              <tbody>
6724                <tr>
6725                  <td align="LEFT" valign="TOP">\001\n</td>
6726
6727                  <td align="LEFT" valign="TOP">abort</td>
6728                </tr>
6729
6730                <tr>
6731                  <td align="LEFT" valign="TOP">\002nnnn
6732                  cfname</td>
6733
6734                  <td align="LEFT" valign="TOP">control file
6735                  transfer</td>
6736                </tr>
6737
6738                <tr>
6739                  <td align="LEFT" valign="TOP">\003nnnn
6740                  dfname</td>
6741
6742                  <td align="LEFT" valign="TOP">data file
6743                  transfer</td>
6744                </tr>
6745              </tbody>
6746            </table>
6747          </div>
6748          <br>
6749          <br>
6750
6751          <p>The abort operation is used to terminate job transfer
6752          and indicate that the job should not be processed for
6753          printing. The connection will be closed and the partly
6754          transferred job will be discarded.</p>
6755
6756          <p>The control file and data file transfer commands have
6757          a length (in bytes) of the file and the name of the file
6758          to be transferred. When the command is received, the
6759          server will reply with a status line:</p>
6760
6761          <div class="INFORMALTABLE">
6762            <a name="AEN1942"></a>
6763
6764            <table border="1" class="CALSTABLE">
6765              <thead>
6766                <tr>
6767                  <th align="LEFT" valign="TOP">Status</th>
6768
6769                  <th align="LEFT" valign="TOP">Purpose</th>
6770                </tr>
6771              </thead>
6772
6773              <tbody>
6774                <tr>
6775                  <td align="LEFT" valign="TOP">\000</td>
6776
6777                  <td align="LEFT" valign="TOP">Accepted,
6778                  proceed</td>
6779                </tr>
6780
6781                <tr>
6782                  <td align="LEFT" valign="TOP">\nnn</td>
6783
6784                  <td align="LEFT" valign="TOP">Rejected with error
6785                  code</td>
6786                </tr>
6787              </tbody>
6788            </table>
6789          </div>
6790          <br>
6791          <br>
6792
6793          <p>The reply is only a single octet. Some defective
6794          implementations of RFC1179 send a LF after the octet,
6795          which makes life very difficult. <b class=
6796          "APPLICATION">LPRng</b> makes an effort to detect these
6797          non-conforming RFC1179 systems and will accept jobs from
6798          them. However, it will not send jobs to them.</p>
6799
6800          <p>If <b class="APPLICATION">LPRng</b> sends a reject
6801          code, as an extension to RFC1179 it also sends an error
6802          message. Note that the values for error codes are not
6803          defined, nor are their causes. <b class=
6804          "APPLICATION">LPRng</b> uses the following values for
6805          error codes, which appear to be compatible with many, but
6806          not all, of the BSD <b class="APPLICATION">lpd</b> based
6807          systems:</p>
6808
6809          <div class="INFORMALTABLE">
6810            <a name="AEN1961"></a>
6811
6812            <table border="1" class="CALSTABLE">
6813              <thead>
6814                <tr>
6815                  <th align="LEFT" valign="TOP">Code</th>
6816
6817                  <th align="LEFT" valign="TOP">Error</th>
6818                </tr>
6819              </thead>
6820
6821              <tbody>
6822                <tr>
6823                  <td align="LEFT" valign="TOP">\000</td>
6824
6825                  <td align="LEFT" valign="TOP">Accepted,
6826                  proceed</td>
6827                </tr>
6828
6829                <tr>
6830                  <td align="LEFT" valign="TOP">\001</td>
6831
6832                  <td align="LEFT" valign="TOP">Queue not accepting
6833                  jobs</td>
6834                </tr>
6835
6836                <tr>
6837                  <td align="LEFT" valign="TOP">\002</td>
6838
6839                  <td align="LEFT" valign="TOP">Queue temporarily
6840                  full, retry later</td>
6841                </tr>
6842
6843                <tr>
6844                  <td align="LEFT" valign="TOP">\003</td>
6845
6846                  <td align="LEFT" valign="TOP">Bad job format, do
6847                  not retry</td>
6848                </tr>
6849              </tbody>
6850            </table>
6851          </div>
6852          <br>
6853          <br>
6854
6855          <p>When the sender gets the reply indicating success, it
6856          sends the <tt class="LITERAL">nnnn</tt> bytes of the
6857          control or data file, followed by a <tt class=
6858          "LITERAL">\000</tt> octet. The receiver will then reply
6859          as above; a single <tt class="LITERAL">\000</tt> octet
6860          indicating success.</p>
6861
6862          <p>The above procedure is carried out until all data
6863          files and the control file of a job are transferred.</p>
6864
6865          <p>RFC1179 is silent on the following issues:</p>
6866
6867          <ol type="1">
6868            <li>
6869              <p>When sending a job, do you send the control file
6870              first, followed by the data file(s), or the data
6871              files first?</p>
6872            </li>
6873
6874            <li>
6875              <p>When sending multiple jobs, can you send them on a
6876              single connection, or do you have to establish a new
6877              connection for each job?</p>
6878            </li>
6879          </ol>
6880          <br>
6881          <br>
6882
6883          <p><b class="APPLICATION">LPRng</b> will <i class=
6884          "EMPHASIS">accept</i> jobs whether they are sent control
6885          or data files first. By default, it sends the control
6886          file first, followed by the data file. If the destination
6887          system requires that the data files be sent first, the
6888          <tt class="LITERAL">send_data_first</tt> printcap option
6889          can be used to force data files to be sent first.</p>
6890
6891          <p>RFC1179 states that: <a name="AEN1996"></a></p>
6892
6893          <blockquote class="BLOCKQUOTE">
6894            <p>The name of the control file ... should start with
6895            ASCII "cfA", followed by a three digit job number,
6896            followed by the host name which has constructed the
6897            control file.</p>
6898          </blockquote>
6899          <br>
6900          <br>
6901
6902          <p>The <i class="EMPHASIS">should</i> in this wording
6903          indicates that this is simply a guideline, and that other
6904          formats are possible. Some of the major problems with
6905          this format are as follows:</p>
6906
6907          <ol type="1">
6908            <li>
6909              <p>The restriction to 3 digits means that at most
6910              1000 jobs can be in a queue. Strangely, some systems
6911              generate far more than 1000 jobs a day, and need to
6912              archive them on a regular basis. The <tt class=
6913              "LITERAL">longnumber</tt> option will allow <b class=
6914              "APPLICATION">LPRng</b> to use a 6 digit job number
6915              for files in the print queue.</p>
6916            </li>
6917
6918            <li>
6919              <p>The host name format is not specified. Some
6920              implementations consider that this is the short host
6921              name, while others think it is the fully qualified
6922              domain name (FQDN). <b class="APPLICATION">LPRng</b>,
6923              by default, will use the FQDN host name. However, the
6924              <tt class="LITERAL">use_shorthost</tt> option will
6925              force it to use short host names in control and data
6926              files.</p>
6927            </li>
6928
6929            <li>
6930              <p>The <tt class="LITERAL">cfA</tt> control file name
6931              was modified to allow the job priority to be used as
6932              the A letter of the control file. By default, this is
6933              A (lowest, i.e. <tt class="LITERAL">cfA</tt>) and but
6934              can range to Z (highest, i.e. <tt class=
6935              "LITERAL">cfZ</tt>). All known spoolers except <b
6936              class="APPLICATION">LPRng</b> seem to ignore the
6937              actual value of the letter.</p>
6938            </li>
6939          </ol>
6940          <br>
6941          <br>
6942        </div>
6943
6944        <div class="SECT1">
6945          <hr>
6946
6947          <h1 class="SECT1"><a name="AEN2015">C.4. Data File
6948          Transfer</a></h1>
6949
6950          <p>As mentioned before a data file is transferred using
6951          the command below.</p>
6952
6953          <div class="INFORMALTABLE">
6954            <a name="AEN2018"></a>
6955
6956            <table border="1" class="CALSTABLE">
6957              <thead>
6958                <tr>
6959                  <th align="LEFT" valign="TOP">Command</th>
6960
6961                  <th align="LEFT" valign="TOP">Purpose</th>
6962                </tr>
6963              </thead>
6964
6965              <tbody>
6966                <tr>
6967                  <td align="LEFT" valign="TOP">\003nnnn
6968                  dfname</td>
6969
6970                  <td align="LEFT" valign="TOP">data file
6971                  transfer</td>
6972                </tr>
6973              </tbody>
6974            </table>
6975          </div>
6976          <br>
6977          <br>
6978
6979          <p>From RFC1179: <a name="AEN2029"></a></p>
6980
6981          <blockquote class="BLOCKQUOTE">
6982            <p>The data file may contain any 8 bit values at all.
6983            The total number of bytes in the stream may be sent as
6984            the first operand, otherwise the field should be
6985            cleared to 0. The name of the data file should start
6986            with ASCII "dfA". This should be followed by a three
6987            digit job number. The job number should be followed by
6988            the host name which has constructed the data file.
6989            Interpretation of the contents of the data file is
6990            determined by the contents of the corresponding control
6991            file.</p>
6992          </blockquote>
6993          <br>
6994          <br>
6995
6996          <p>There are several surprises in RFC1179.</p>
6997
6998          <ol type="1">
6999            <li>
7000              <p>Apparently a job should only consist of a single
7001              data file. This is a severe limitation, and in fact
7002              the BSD <b class="APPLICATION">lpr</b> and other
7003              print spoolers process jobs with multiple data files.
7004              By convention, these data files have names of the
7005              form <tt class="LITERAL">dfA</tt>, <tt class=
7006              "LITERAL">dfB</tt>, ... <tt class="LITERAL">dfZ</tt>,
7007              <tt class="LITERAL">dfa</tt>, <tt class=
7008              "LITERAL">dfz</tt>.</p>
7009            </li>
7010
7011            <li>
7012              <p>The RFC does not specify that the control file and
7013              data file job numbers must be identical. Most
7014              implementations follow this convention, which
7015              simplifies life tremendously.</p>
7016            </li>
7017
7018            <li>
7019              <p>The RFC does not specify that the control file and
7020              data file job host names must be identical. Most
7021              implementations follow this convention, which
7022              simplifies life tremendously.</p>
7023            </li>
7024
7025            <li>
7026              <p>A zero length data file does not cause a data
7027              transfer to take place. <b class=
7028              "APPLICATION">LPRng</b> modifies this action to be
7029              slightly different. When a zero length data file
7030              transfer is indicated, all of the input until the
7031              connection is closed is used as the contents of the
7032              data file.</p>
7033
7034              <p>When <i class="EMPHASIS">piping</i> into the <b
7035              class="APPLICATION">lpr</b> program, this can be very
7036              useful as it eliminates the need to create temporary
7037              files on the local host. Note that some print
7038              spoolers do not use this interpretation, and this
7039              option should be used carefully.</p>
7040            </li>
7041          </ol>
7042          <br>
7043          <br>
7044        </div>
7045
7046        <div class="SECT1">
7047          <hr>
7048
7049          <h1 class="SECT1"><a name="AEN2051">C.5. Control File
7050          Contents</a></h1>
7051
7052          <p>The control file consists of a set of lines which
7053          either provide printing information or specify data files
7054          to be printed. The information lines start with upper
7055          case letters or digits, while the data files lines start
7056          with lower case letters. Here is a sample control
7057          file:</p>
7058
7059          <div class="INFORMALEXAMPLE">
7060            <a name="AEN2054"></a>
7061<pre class="SCREEN">
7062    Hh4.private
7063    J(stdin)
7064    CA
7065    Lpapowell
7066    Apapowell@h4+955
7067    Ppapowell
7068    fdfA955h4.private
7069    N(stdin)
7070    UdfA955h4.private
7071</pre>
7072          </div>
7073          <br>
7074          <br>
7075
7076          <p>The following are the letters and their meanings in
7077          the control file.</p>
7078
7079          <div class="TABLE">
7080            <a name="CFLINES"></a>
7081
7082            <p><b>Table C-2. Control File Lines and Purpose</b></p>
7083
7084            <table border="1" class="CALSTABLE">
7085              <thead>
7086                <tr>
7087                  <th align="LEFT" valign="TOP">Letter</th>
7088
7089                  <th align="LEFT" valign="TOP">Defined</th>
7090
7091                  <th align="LEFT" valign="TOP">Purpose</th>
7092                </tr>
7093              </thead>
7094
7095              <tbody>
7096                <tr>
7097                  <td align="LEFT" valign="TOP">A</td>
7098
7099                  <td align="LEFT" valign="TOP"><b class=
7100                  "APPLICATION">LPRng</b></td>
7101
7102                  <td align="LEFT" valign="TOP">Identifier for
7103                  job</td>
7104                </tr>
7105
7106                <tr>
7107                  <td align="LEFT" valign="TOP">C</td>
7108
7109                  <td align="LEFT" valign="TOP">RFC1179</td>
7110
7111                  <td align="LEFT" valign="TOP">Class for banner
7112                  page</td>
7113                </tr>
7114
7115                <tr>
7116                  <td align="LEFT" valign="TOP">H</td>
7117
7118                  <td align="LEFT" valign="TOP">RFC1179</td>
7119
7120                  <td align="LEFT" valign="TOP">Host name</td>
7121                </tr>
7122
7123                <tr>
7124                  <td align="LEFT" valign="TOP">I</td>
7125
7126                  <td align="LEFT" valign="TOP">RFC1179</td>
7127
7128                  <td align="LEFT" valign="TOP">Indent
7129                  Printing</td>
7130                </tr>
7131
7132                <tr>
7133                  <td align="LEFT" valign="TOP">J</td>
7134
7135                  <td align="LEFT" valign="TOP">RFC1179</td>
7136
7137                  <td align="LEFT" valign="TOP">Job name for banner
7138                  page</td>
7139                </tr>
7140
7141                <tr>
7142                  <td align="LEFT" valign="TOP">L</td>
7143
7144                  <td align="LEFT" valign="TOP">RFC1179</td>
7145
7146                  <td align="LEFT" valign="TOP">Print banner
7147                  page</td>
7148                </tr>
7149
7150                <tr>
7151                  <td align="LEFT" valign="TOP">M</td>
7152
7153                  <td align="LEFT" valign="TOP">RFC1179</td>
7154
7155                  <td align="LEFT" valign="TOP">Mail When
7156                  Printed</td>
7157                </tr>
7158
7159                <tr>
7160                  <td align="LEFT" valign="TOP">N</td>
7161
7162                  <td align="LEFT" valign="TOP">RFC1179</td>
7163
7164                  <td align="LEFT" valign="TOP">Name of source
7165                  file</td>
7166                </tr>
7167
7168                <tr>
7169                  <td align="LEFT" valign="TOP">P</td>
7170
7171                  <td align="LEFT" valign="TOP">RFC1179</td>
7172
7173                  <td align="LEFT" valign="TOP">User
7174                  identification</td>
7175                </tr>
7176
7177                <tr>
7178                  <td align="LEFT" valign="TOP">Q</td>
7179
7180                  <td align="LEFT" valign="TOP"><b class=
7181                  "APPLICATION">LPRng</b></td>
7182
7183                  <td align="LEFT" valign="TOP">Queue name</td>
7184                </tr>
7185
7186                <tr>
7187                  <td align="LEFT" valign="TOP">R</td>
7188
7189                  <td align="LEFT" valign="TOP"><b class=
7190                  "APPLICATION">LPRng</b></td>
7191
7192                  <td align="LEFT" valign="TOP">Accounting
7193                  info</td>
7194                </tr>
7195
7196                <tr>
7197                  <td align="LEFT" valign="TOP">S</td>
7198
7199                  <td align="LEFT" valign="TOP">RFC1179</td>
7200
7201                  <td align="LEFT" valign="TOP">Symbolic link
7202                  data</td>
7203                </tr>
7204
7205                <tr>
7206                  <td align="LEFT" valign="TOP">T</td>
7207
7208                  <td align="LEFT" valign="TOP">RFC1179</td>
7209
7210                  <td align="LEFT" valign="TOP">Title for pr</td>
7211                </tr>
7212
7213                <tr>
7214                  <td align="LEFT" valign="TOP">U</td>
7215
7216                  <td align="LEFT" valign="TOP">RFC1179</td>
7217
7218                  <td align="LEFT" valign="TOP">Unlink data
7219                  file</td>
7220                </tr>
7221
7222                <tr>
7223                  <td align="LEFT" valign="TOP">W</td>
7224
7225                  <td align="LEFT" valign="TOP">RFC1179</td>
7226
7227                  <td align="LEFT" valign="TOP">Width of
7228                  output</td>
7229                </tr>
7230
7231                <tr>
7232                  <td align="LEFT" valign="TOP">Z</td>
7233
7234                  <td align="LEFT" valign="TOP"><b class=
7235                  "APPLICATION">LPRng</b></td>
7236
7237                  <td align="LEFT" valign="TOP">Filter options</td>
7238                </tr>
7239
7240                <tr>
7241                  <td align="LEFT" valign="TOP">1</td>
7242
7243                  <td align="LEFT" valign="TOP">RFC1179</td>
7244
7245                  <td align="LEFT" valign="TOP">troff R font</td>
7246                </tr>
7247
7248                <tr>
7249                  <td align="LEFT" valign="TOP">2</td>
7250
7251                  <td align="LEFT" valign="TOP">RFC1179</td>
7252
7253                  <td align="LEFT" valign="TOP">troff I font</td>
7254                </tr>
7255
7256                <tr>
7257                  <td align="LEFT" valign="TOP">3</td>
7258
7259                  <td align="LEFT" valign="TOP">RFC1179</td>
7260
7261                  <td align="LEFT" valign="TOP">troff B font</td>
7262                </tr>
7263
7264                <tr>
7265                  <td align="LEFT" valign="TOP">4</td>
7266
7267                  <td align="LEFT" valign="TOP">RFC1179</td>
7268
7269                  <td align="LEFT" valign="TOP">troff S font</td>
7270                </tr>
7271
7272                <tr>
7273                  <td align="LEFT" valign="TOP">c</td>
7274
7275                  <td align="LEFT" valign="TOP">RFC1179</td>
7276
7277                  <td align="LEFT" valign="TOP">Plot CIF file</td>
7278                </tr>
7279
7280                <tr>
7281                  <td align="LEFT" valign="TOP">d</td>
7282
7283                  <td align="LEFT" valign="TOP">RFC1179</td>
7284
7285                  <td align="LEFT" valign="TOP">Print DVI file</td>
7286                </tr>
7287
7288                <tr>
7289                  <td align="LEFT" valign="TOP">f</td>
7290
7291                  <td align="LEFT" valign="TOP">RFC1179</td>
7292
7293                  <td align="LEFT" valign="TOP">Print formatted
7294                  file</td>
7295                </tr>
7296
7297                <tr>
7298                  <td align="LEFT" valign="TOP">g</td>
7299
7300                  <td align="LEFT" valign="TOP">RFC1179</td>
7301
7302                  <td align="LEFT" valign="TOP">Plot file</td>
7303                </tr>
7304
7305                <tr>
7306                  <td align="LEFT" valign="TOP">k</td>
7307
7308                  <td align="LEFT" valign="TOP">RFC1179</td>
7309
7310                  <td align="LEFT" valign="TOP">Reserved for use by
7311                  Kerberized <b class="APPLICATION">LPRng</b>
7312                  clients and servers.</td>
7313                </tr>
7314
7315                <tr>
7316                  <td align="LEFT" valign="TOP">l</td>
7317
7318                  <td align="LEFT" valign="TOP">RFC1179</td>
7319
7320                  <td align="LEFT" valign="TOP">Print file leaving
7321                  control characters</td>
7322                </tr>
7323
7324                <tr>
7325                  <td align="LEFT" valign="TOP">n</td>
7326
7327                  <td align="LEFT" valign="TOP">RFC1179</td>
7328
7329                  <td align="LEFT" valign="TOP">Print ditroff
7330                  output file</td>
7331                </tr>
7332
7333                <tr>
7334                  <td align="LEFT" valign="TOP">o</td>
7335
7336                  <td align="LEFT" valign="TOP">RFC1179</td>
7337
7338                  <td align="LEFT" valign="TOP">Print Postscript
7339                  output file</td>
7340                </tr>
7341
7342                <tr>
7343                  <td align="LEFT" valign="TOP">p</td>
7344
7345                  <td align="LEFT" valign="TOP">RFC1179</td>
7346
7347                  <td align="LEFT" valign="TOP">Print file with
7348                  'pr' format</td>
7349                </tr>
7350
7351                <tr>
7352                  <td align="LEFT" valign="TOP">t</td>
7353
7354                  <td align="LEFT" valign="TOP">RFC1179</td>
7355
7356                  <td align="LEFT" valign="TOP">Print troff output
7357                  file</td>
7358                </tr>
7359
7360                <tr>
7361                  <td align="LEFT" valign="TOP">v</td>
7362
7363                  <td align="LEFT" valign="TOP">RFC1179</td>
7364
7365                  <td align="LEFT" valign="TOP">Print raster
7366                  file</td>
7367                </tr>
7368
7369                <tr>
7370                  <td align="LEFT" valign="TOP">z</td>
7371
7372                  <td align="LEFT" valign="TOP">RFC1179</td>
7373
7374                  <td align="LEFT" valign="TOP">Reserved for future
7375                  use with the Palladium print system.</td>
7376                </tr>
7377              </tbody>
7378            </table>
7379          </div>
7380
7381          <p>The <tt class="LITERAL">A</tt> (Identifier) line was
7382          introduced to record a unique system wide job identifier
7383          for <b class="APPLICATION">LPRng</b> submitted jobs. This
7384          is basically formed from the user name, job number, and
7385          host at the time of submission. For example: <tt class=
7386          "LITERAL">papowell@h4+955</tt> is job number 995
7387          submitted by papowell from host h4.</p>
7388
7389          <p>The <tt class="LITERAL">C</tt> (Class) line is set by
7390          the <tt class="COMMAND">lpr -C class</tt> option, and the
7391          value can be used to control printing. For example, the
7392          <tt class="COMMAND">lpc class zone</tt> command would
7393          restrict job printing to only jobs with class <tt class=
7394          "LITERAL">zone</tt>.</p>
7395
7396          <p>The <tt class="LITERAL">H</tt> (hostname), <tt class=
7397          "LITERAL">P</tt> (username), and <tt class=
7398          "LITERAL">J</tt> (jobname) fields are used to identify
7399          the host and user which sent the job, and to provide
7400          information to be displayed by <b class=
7401          "APPLICATION">lpq</b> when reporting job status.</p>
7402
7403          <p>The <tt class="LITERAL">L</tt> (print banner page)
7404          field is one that has caused many problems for users.
7405          RFC1179 indicates that its presence causes the banner
7406          page to be printed, and its absence suppresses banner
7407          pages. The <tt class="COMMAND">lpr -h</tt> option
7408          suppresses putting this line into the control file.
7409          Usually the <tt class="LITERAL">L</tt> field is a
7410          duplicate of the <tt class="LITERAL">P</tt> field.</p>
7411
7412          <p>The <tt class="LITERAL">M</tt> (mail information)
7413          field supplies a mail address for <b class=
7414          "APPLICATION">LPRng</b> to send mail to when a job is
7415          completed.</p>
7416
7417          <p>The <tt class="LITERAL">N</tt> (file name) field is
7418          usually provided to identify the file name corresponding
7419          to the data file. This can be used to print names on page
7420          separators, etc. <b class="APPLICATION">LPRng</b> largely
7421          ignores this line.</p>
7422
7423          <p>The <tt class="LITERAL">I</tt> (indent) and <tt class=
7424          "LITERAL">W</tt> (width) fields are supposed to specify a
7425          page indent and width for printing. These fields are
7426          passed to filters if they are present.</p>
7427
7428          <p>The <tt class="LITERAL">Q</tt> (queue name) field is
7429          an <b class="APPLICATION">LPRng</b> extension, and
7430          contains the name of the print queue the job was
7431          originally sent to.&#13;</p>
7432
7433          <p>The <tt class="LITERAL">R</tt> (accounting info) field
7434          was added by <b class="APPLICATION">LPRng</b> to allow a
7435          specified account to be billed for job printing. The <tt
7436          class="COMMAND">lpr -Rname</tt> option can be used to
7437          specify the accounting name.</p>
7438
7439          <p>The <tt class="LITERAL">S</tt> (symbolic link) and <tt
7440          class="LITERAL">U</tt> (unlink after printing) lines were
7441          used by the original BSD <b class="APPLICATION">lpd</b>
7442          print system to control how it passed files to the print
7443          server. <b class="APPLICATION">LPRng</b> ignores these
7444          lines. In fact, it will remove <tt class="LITERAL">S</tt>
7445          lines and force the <tt class="LITERAL">U</tt> lines to
7446          refer only to job data files. This closes a nasty
7447          security loophole on non-<b class="APPLICATION">LPRng</b>
7448          print spoolers.</p>
7449
7450          <p>The <tt class="LITERAL">T</tt> (pr job title) is used
7451          with the <tt class="COMMAND">lpr -p</tt> operation to
7452          supply a banner to the <tt class="LITERAL">pr</tt>
7453          program.</p>
7454
7455          <p>The <tt class="LITERAL">Z</tt> (filter options) value
7456          is specified with <tt class="COMMAND">lpr -Zoption</tt>
7457          and is passed to the data file filters during the
7458          printing operation.</p>
7459
7460          <p>All of the lower case letters are reserved for format
7461          specifications for data files. In the control file, these
7462          are followed by the name of the data file to which they
7463          correspond. While in principle different data files in
7464          the control file can have different formats, this has not
7465          been implemented in any known spooling system.</p>
7466        </div>
7467
7468        <div class="SECT1">
7469          <hr>
7470
7471          <h1 class="SECT1"><a name="AEN2250">C.6. <b class=
7472          "APPLICATION">lpq</b> Requests</a></h1>
7473
7474          <p>The RFC1179 protocol specifies that <b class=
7475          "APPLICATION">lpq</b> print status requests can be sent
7476          to the <b class="APPLICATION">lpd</b> server. The lpq
7477          requests have the format:</p>
7478
7479          <div class="INFORMALEXAMPLE">
7480            <a name="AEN2256"></a>
7481<pre class="SCREEN">
7482    \003printer [id]* \n    short
7483    \004printer [id]* \n    long
7484    \009printer [id]* \n    <b class=
7485"APPLICATION">LPRng</b> extension- verbose
7486</pre>
7487          </div>
7488          <br>
7489          <br>
7490
7491          <p>The <b class="APPLICATION">lpd</b> print server will
7492          then return queue status and close the data
7493          connection.</p>
7494
7495          <p>RFC1179 does not state in any manner what the format
7496          of the queue status should be. Thus, implementors have
7497          been free to augment or change the status as they like.
7498          Even the BSD <b class="APPLICATION">lpq</b> status format
7499          has been changed from different versions.</p>
7500
7501          <p>The <tt class="LITERAL">id</tt> values are used to
7502          select the jobs to be displayed. <b class=
7503          "APPLICATION">LPRng</b> displays any job whose ID,
7504          hostname, or user name information from the control file
7505          <tt class="LITERAL">A</tt>, <tt class="LITERAL">H</tt>,
7506          or <tt class="LITERAL">P</tt> fields match any of the id
7507          values.</p>
7508
7509          <p>Note that since there is no identification of the
7510          information requestor, then restriction of information is
7511          almost impossible.</p>
7512        </div>
7513
7514        <div class="SECT1">
7515          <hr>
7516
7517          <h1 class="SECT1"><a name="AEN2270">C.7. <b class=
7518          "APPLICATION">lprm</b> Requests</a></h1>
7519
7520          <p>The RFC1179 protocol specifies that <b class=
7521          "APPLICATION">lprm</b> job removal requests can be sent
7522          to the <b class="APPLICATION">lpd</b> server. The lpq
7523          requests have the format:</p>
7524
7525          <div class="INFORMALEXAMPLE">
7526            <a name="AEN2276"></a>
7527<pre class="SCREEN">
7528    \005printer user [id]* \n
7529</pre>
7530          </div>
7531          <br>
7532          <br>
7533
7534          <p>The <b class="APPLICATION">lpd</b> print server will
7535          search the specified print queue and remove any job whose
7536          ID, hostname, or user name information from the control
7537          file <tt class="LITERAL">A</tt>, <tt class=
7538          "LITERAL">H</tt>, or <tt class="LITERAL">P</tt> fields
7539          match any of the id values and for which the user has
7540          permission to perform a removal operation.</p>
7541
7542          <p>Most RFC1179 compatible spoolers use the user
7543          information in the request as the name of the user which
7544          spooled the job. However, in a network environment this
7545          is extremely easy to fabricate, and is at best a weak
7546          type of authentication.</p>
7547        </div>
7548
7549        <div class="SECT1">
7550          <hr>
7551
7552          <h1 class="SECT1"><a name="LPCREREAD">C.8. LPC
7553          Requests</a></h1>
7554
7555          <p><b class="APPLICATION">LPRng</b> has extended the
7556          RFC1179 protocol to allow queue and printer control
7557          commands to be sent to the <b class="APPLICATION">lpd</b>
7558          server. The format of these commands are:</p>
7559
7560          <div class="INFORMALEXAMPLE">
7561            <a name="AEN2290"></a>
7562<pre class="SCREEN">
7563    \006printer user key [options]
7564</pre>
7565          </div>
7566          <br>
7567          <br>
7568
7569          <p>The following commands are supported.</p>
7570
7571          <div class="TABLE">
7572            <a name="LPCCOMMANDS"></a>
7573
7574            <p><b>Table C-3. LPC Commands</b></p>
7575
7576            <table border="1" class="CALSTABLE">
7577              <thead>
7578                <tr>
7579                  <th align="LEFT" valign="TOP">Command</th>
7580
7581                  <th align="LEFT" valign="TOP">Operation</th>
7582                </tr>
7583              </thead>
7584
7585              <tbody>
7586                <tr>
7587                  <td align="LEFT" valign="TOP">Command</td>
7588
7589                  <td align="LEFT" valign="TOP">Operation</td>
7590                </tr>
7591
7592                <tr>
7593                  <td align="LEFT" valign="TOP"><tt class=
7594                  "LITERAL">active [printer[@host]]</tt></td>
7595
7596                  <td align="LEFT" valign="TOP">check to see if
7597                  server accepting connections</td>
7598                </tr>
7599
7600                <tr>
7601                  <td align="LEFT" valign="TOP"><tt class=
7602                  "LITERAL">abort (printer[@host] | all)</tt> </td>
7603
7604                  <td align="LEFT" valign="TOP">terminate server
7605                  process printing job</td>
7606                </tr>
7607
7608                <tr>
7609                  <td align="LEFT" valign="TOP"><tt class=
7610                  "LITERAL">disable (printer[@host] | all)</tt>
7611                  </td>
7612
7613                  <td align="LEFT" valign="TOP">disable
7614                  queueing</td>
7615                </tr>
7616
7617                <tr>
7618                  <td align="LEFT" valign="TOP"><tt class=
7619                  "LITERAL">debug (printer[@host] | all)
7620                  debugparms</tt> </td>
7621
7622                  <td align="LEFT" valign="TOP">set debug level for
7623                  printer</td>
7624                </tr>
7625
7626                <tr>
7627                  <td align="LEFT" valign="TOP"><tt class=
7628                  "LITERAL">enable (printer[@host] | all)</tt>
7629                  </td>
7630
7631                  <td align="LEFT" valign="TOP">enable
7632                  queueing</td>
7633                </tr>
7634
7635                <tr>
7636                  <td align="LEFT" valign="TOP"><tt class=
7637                  "LITERAL">hold (printer[@host] | all)
7638                  (name[@host] | job | all)*</tt> </td>
7639
7640                  <td align="LEFT" valign="TOP">hold job</td>
7641                </tr>
7642
7643                <tr>
7644                  <td align="LEFT" valign="TOP"><tt class=
7645                  "LITERAL">holdall (printer[@host] | all)</tt>
7646                  </td>
7647
7648                  <td align="LEFT" valign="TOP">hold all jobs
7649                  on</td>
7650                </tr>
7651
7652                <tr>
7653                  <td align="LEFT" valign="TOP"><tt class=
7654                  "LITERAL">kill (printer[@host] | all)</tt> </td>
7655
7656                  <td align="LEFT" valign="TOP">stop and restart
7657                  server</td>
7658                </tr>
7659
7660                <tr>
7661                  <td align="LEFT" valign="TOP"><tt class=
7662                  "LITERAL">lpd [printer[@host]]</tt> </td>
7663
7664                  <td align="LEFT" valign="TOP">get <b class=
7665                  "APPLICATION">lpd</b> PID for server</td>
7666                </tr>
7667
7668                <tr>
7669                  <td align="LEFT" valign="TOP"><tt class=
7670                  "LITERAL">lpq (printer[@host] | all) (name[@host]
7671                  | job | all)*</tt> </td>
7672
7673                  <td align="LEFT" valign="TOP">invoke <b class=
7674                  "APPLICATION">lpq</b></td>
7675                </tr>
7676
7677                <tr>
7678                  <td align="LEFT" valign="TOP"><tt class=
7679                  "LITERAL">lprm (printer[@host] | all)
7680                  (name[@host]|host|job| all)*</tt> </td>
7681
7682                  <td align="LEFT" valign="TOP">invoke <b class=
7683                  "APPLICATION">lprm</b></td>
7684                </tr>
7685
7686                <tr>
7687                  <td align="LEFT" valign="TOP"><tt class=
7688                  "LITERAL">move printer (user|jobid)* target</tt>
7689                  </td>
7690
7691                  <td align="LEFT" valign="TOP">move jobs to new
7692                  queue</td>
7693                </tr>
7694
7695                <tr>
7696                  <td align="LEFT" valign="TOP"><tt class=
7697                  "LITERAL">noholdall (printer[@host] | all)</tt>
7698                  </td>
7699
7700                  <td align="LEFT" valign="TOP">hold all jobs
7701                  off</td>
7702                </tr>
7703
7704                <tr>
7705                  <td align="LEFT" valign="TOP"><tt class=
7706                  "LITERAL">printcap (printer[@host] | all)</tt>
7707                  </td>
7708
7709                  <td align="LEFT" valign="TOP">report printcap
7710                  values</td>
7711                </tr>
7712
7713                <tr>
7714                  <td align="LEFT" valign="TOP"><tt class=
7715                  "LITERAL">quit</tt> </td>
7716
7717                  <td align="LEFT" valign="TOP">exit LPC</td>
7718                </tr>
7719
7720                <tr>
7721                  <td align="LEFT" valign="TOP"><tt class=
7722                  "LITERAL">redirect (printer[@host] | all)
7723                  (printer@host | off )*</tt> </td>
7724
7725                  <td align="LEFT" valign="TOP">redirect jobs</td>
7726                </tr>
7727
7728                <tr>
7729                  <td align="LEFT" valign="TOP"><tt class=
7730                  "LITERAL">release (printer[@host] | all)
7731                  (name[@host] | job | all)*</tt> </td>
7732
7733                  <td align="LEFT" valign="TOP">release job</td>
7734                </tr>
7735
7736                <tr>
7737                  <td align="LEFT" valign="TOP"><tt class=
7738                  "LITERAL">reread [printer[@host]]</tt></td>
7739
7740                  <td align="LEFT" valign="TOP"><b class=
7741                  "APPLICATION">lpd</b> reread database
7742                  information</td>
7743                </tr>
7744
7745                <tr>
7746                  <td align="LEFT" valign="TOP"><tt class=
7747                  "LITERAL">start (printer[@host] | all)</tt> </td>
7748
7749                  <td align="LEFT" valign="TOP">start printing</td>
7750                </tr>
7751
7752                <tr>
7753                  <td align="LEFT" valign="TOP"><tt class=
7754                  "LITERAL">status (printer[@host] | all)</tt>
7755                  </td>
7756
7757                  <td align="LEFT" valign="TOP">status of
7758                  printers</td>
7759                </tr>
7760
7761                <tr>
7762                  <td align="LEFT" valign="TOP"><tt class=
7763                  "LITERAL">stop (printer[@host] | all)</tt> </td>
7764
7765                  <td align="LEFT" valign="TOP">stop printing</td>
7766                </tr>
7767
7768                <tr>
7769                  <td align="LEFT" valign="TOP"><tt class=
7770                  "LITERAL">topq (printer[@host] | all)
7771                  (name[@host] | job | all)*</tt> </td>
7772
7773                  <td align="LEFT" valign="TOP">reorder job</td>
7774                </tr>
7775
7776                <tr>
7777                  <td align="LEFT" valign="TOP"><tt class=
7778                  "LITERAL">defaultq</tt> </td>
7779
7780                  <td align="LEFT" valign="TOP">default queue for
7781                  <b class="APPLICATION">lpd</b> server</td>
7782                </tr>
7783
7784                <tr>
7785                  <td align="LEFT" valign="TOP"><tt class=
7786                  "LITERAL">local (printer | all)</tt> </td>
7787
7788                  <td align="LEFT" valign="TOP">client printcap and
7789                  configuration information</td>
7790                </tr>
7791
7792                <tr>
7793                  <td align="LEFT" valign="TOP"><tt class=
7794                  "LITERAL">server (printer | all)</tt> </td>
7795
7796                  <td align="LEFT" valign="TOP">server printcap and
7797                  configuration information</td>
7798                </tr>
7799              </tbody>
7800            </table>
7801          </div>
7802
7803          <p>Many of these commands support extremely specialized
7804          operations for print queue management, However, the
7805          following are the most commonly used and are supported by
7806          the BSD <b class="APPLICATION">lpd</b> print spooling
7807          system as well:</p>
7808
7809          <ul>
7810            <li>
7811              <p><tt class="LITERAL">start, stop, enable,
7812              disable</tt> Start and stop will start and stop
7813              printing for a specified queue. Enable and disable
7814              enable and disable sending and/or accepting jobs for
7815              the queue.</p>
7816            </li>
7817
7818            <li>
7819              <p><tt class="LITERAL">abort, kill</tt> Abort will
7820              cause the process doing the actual job printing to be
7821              terminated. Kill does an abort, and then restarts the
7822              printing process. These commands are used to restart
7823              a queue printing after some disaster.</p>
7824            </li>
7825
7826            <li>
7827              <p><tt class="LITERAL">topq</tt> Places selected jobs
7828              at the top of the print queue.</p>
7829            </li>
7830
7831            <li>
7832              <p><tt class="LITERAL">status</tt> Shows a status
7833              display of the print spools on the server.</p>
7834            </li>
7835          </ul>
7836          <br>
7837          <br>
7838
7839          <p>The following commands are extensions to the basic set
7840          provided by the BSD <b class="APPLICATION">lpd</b>
7841          system.</p>
7842
7843          <ul>
7844            <li>
7845              <p><tt class="LITERAL">lpq, lprm</tt> Invokes the lpq
7846              or lprm program from lpc. Useful when in the
7847              interactive mode.</p>
7848            </li>
7849
7850            <li>
7851              <p><tt class="LITERAL">hold, holdall, release</tt>
7852              The hold command will cause the selected jobs to be
7853              held until released. The holdall jobs sets all jobs
7854              submitted to the queue to be held until released. The
7855              release command releases jobs for printing. If a job
7856              has had an error and is in the error state, the
7857              release command will cause it to be reprinted.</p>
7858            </li>
7859
7860            <li>
7861              <p><tt class="LITERAL">move, redirect</tt> The move
7862              command will move selected jobs to the specified
7863              spool queue. The redirect command sends all jobs
7864              submitted to the queue to be sent to the specified
7865              queue.</p>
7866            </li>
7867
7868            <li>
7869              <p><tt class="LITERAL">active, lpd, reread</tt> The
7870              active command will connect to the server for the
7871              printer. This is used to check to see if non-<b
7872              class="APPLICATION">LPRng</b> print servers are
7873              active. The lpd command will connect to the server
7874              and get the process id (PID) of the <b class=
7875              "APPLICATION">lpd</b> server. The reread command
7876              causes a SIGHUP signal to be sent to the lpd process,
7877              causing it to reread the <tt class=
7878              "FILENAME">lpd.conf</tt>, <tt class=
7879              "FILENAME">printcap</tt>, and <tt class=
7880              "FILENAME">lpd.perms</tt> files. This is done when
7881              configuration information has been modified and the
7882              administrator wants to have the server use the new
7883              information.</p>
7884            </li>
7885
7886            <li>
7887              <p><tt class="LITERAL">debug</tt> This is a
7888              desperation facility for developers that allows
7889              dynamic enabling of debug information generation. Not
7890              normally used in general operation.</p>
7891            </li>
7892
7893            <li>
7894              <p><tt class="LITERAL">local, server</tt> These
7895              commands will print out the configuration information
7896              in the local <tt class="FILENAME">lpd.conf</tt> file,
7897              as well as the printcap information for the specified
7898              printers; <tt class="LITERAL">client</tt> prints what
7899              the <b class="APPLICATION">LPRng</b> clients (<tt
7900              class="LITERAL">lpr, lpq, ...</tt>) would use while
7901              <tt class="LITERAL">server</tt> prints what the <b
7902              class="APPLICATION">LPRng</b> server (<b class=
7903              "APPLICATION">lpd</b>) would use if running on this
7904              host. This is an extremely useful diagnostic tool for
7905              administrators. Not normally used in general
7906              operation.</p>
7907            </li>
7908          </ul>
7909          <br>
7910          <br>
7911        </div>
7912
7913        <div class="SECT1">
7914          <hr>
7915
7916          <h1 class="SECT1"><a name="SENDBLOCKFORMAT">C.9. Block
7917          Job Transfer</a></h1>
7918
7919          <p>Options used:</p>
7920
7921          <ul>
7922            <li>
7923              <p><tt class="LITERAL">send_block_format</tt> FLAG <i
7924              class="EMPHASIS">Transfer job as a block</i></p>
7925            </li>
7926          </ul>
7927          <br>
7928          <br>
7929
7930          <p>In normal job transfer operations, the sender and
7931          receiver have a handshake interaction in order to
7932          transfer a print job. Each file is sent individually. The
7933          <tt class="LITERAL">send_block_format</tt> option forces
7934          a Block Job Transfer operation. This causes the sender to
7935          transfer a single file containing all the job printing
7936          information, including control file and data files.</p>
7937
7938          <p>The transfer command line has the form:</p>
7939
7940          <div class="INFORMALEXAMPLE">
7941            <a name="AEN2468"></a>
7942<pre class="SCREEN">
7943    \007printer size\n
7944</pre>
7945          </div>
7946          <br>
7947          <br>
7948
7949          <p>The receiver will return any acknowledgement of a
7950          single 0 octet, and then the size bytes of the job will
7951          be transferred by the sender. At the end of the transfer
7952          a single 0 octet is added, and the receiver will indicate
7953          success by returning a single 0 octet. Any other value
7954          returned by the receiver indicates an error
7955          condition.</p>
7956
7957          <p>The file transferred by the sender is simply the
7958          command lines that it would have normally sent for job
7959          transfer, followed by the control or data file
7960          values.</p>
7961        </div>
7962
7963        <div class="SECT1">
7964          <hr>
7965
7966          <h1 class="SECT1"><a name="AEN2472">C.10. Authenticated
7967          Transfer</a></h1>
7968
7969          <p>RFC1179 does not provide any authentication or
7970          encryption mechanism for the transfer of jobs or commands
7971          to the <b class="APPLICATION">lpd</b> print server. The
7972          Authenticated Transfer operation was added to allow an
7973          encrypted or authenticated transfer of print jobs or
7974          commands.</p>
7975
7976          <p>Since there are various restrictions on the
7977          incorporation of authentication facilities into programs,
7978          <b class="APPLICATION">LPRng</b> supports authentication
7979          by providing a simple interface to encryption
7980          programs.</p>
7981
7982          <p>The idea is that when authentication is required when
7983          sending a job, <b class="APPLICATION">LPRng</b> will
7984          generate a block transfer job as described for the <a
7985          href="#SENDBLOCKFORMAT">Block Job Transfer</a> operation,
7986          and then invoke a set of programs to encryt and transfer
7987          the file, and encrypt and transfer the returned
7988          status.</p>
7989
7990          <p>Similarly, when sending a command, the command
7991          information will be placed in a file and the encrypted
7992          file will be transferred.</p>
7993
7994          <p>This technique means that the programs and support to
7995          do encryption are external to <b class=
7996          "APPLICATION">LPRng</b>, and can use any type of method
7997          that they choose to implement the secure and/or
7998          authenticated transfer.</p>
7999        </div>
8000      </div>
8001    </div>
8002    <hr>
8003  </body>
8004</html>
8005
8006