/usr/share/doc/lprng-doc/LPRng-Reference-Multipart/x3103.htm is in lprng-doc 3.8.A~rc2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 6 November 2007), see www.w3.org">
<title>Printcap Basics</title>
<meta name="GENERATOR" content=
"Modular DocBook HTML Stylesheet Version 1.79">
<link rel="HOME" title=" LPRng Reference Manual" href=
"index.htm">
<link rel="UP" title="Print Spooling Tutorial " href=
"tutorial.htm">
<link rel="PREVIOUS" title=
"Job File Format Conversion with Filters" href=
"jobfileformatconversion.htm">
<link rel="NEXT" title="Banner Printing and the OF filter" href=
"x3273.htm">
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF"
vlink="#840084" alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border=
"0" cellpadding="0" cellspacing="0">
<tr>
<th colspan="3" align="center">LPRng Reference Manual: 24
Sep 2004 (For LPRng-3.8.28)</th>
</tr>
<tr>
<td width="10%" align="left" valign="bottom"><a href=
"jobfileformatconversion.htm" accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 4.
Print Spooling Tutorial</td>
<td width="10%" align="right" valign="bottom"><a href=
"x3273.htm" accesskey="N">Next</a></td>
</tr>
</table>
<hr align="left" width="100%">
</div>
<div class="SECT1">
<h1 class="SECT1"><a name="AEN3103" id="AEN3103">4.11. Printcap
Basics</a></h1>
<p>In the previous sections we have used simple printcap
entries to define how to set up filters and pass parameters to
them. We will now examine the printcap database in more
detail.</p>
<p>The <b class="APPLICATION">LPRng</b> server and client
software gets their configuration information from:</p>
<ul>
<li>
<p>Compile time settings which set the default values for
the configuration information.</p>
</li>
<li>
<p>A <tt class="FILENAME">lpd.conf</tt> file that contains
values that override the compile time defaults. This
information can effect the behavior of the <b class=
"APPLICATION">lpd</b> server and clients.</p>
</li>
<li>
<p>Printcap entries which have configuration information
for individual print queues. The information in the
printcap entries for the queue override the <tt class=
"FILENAME">lpd.conf</tt> and compile time defaults. The
system printcap file is read first, followed by the user
printcap file.</p>
</li>
<li>
<p>Command line and environment variable values. These can
be used to override or select particular configuration
information or to select one of a set of options for
use.</p>
</li>
</ul>
<p>Each print queue or printer has a name which is used to look
up the printcap information for the printer. The <tt class=
"FILENAME">/etc/printcap</tt> file is the default location for
the printcap information, although it can also be obtained from
database servers, or generated by programs. See the <a href=
"secnis.htm">Using Programs To Get Printcap Information</a>
section for details.</p>
<p>We will use a more complex printcap file to explore how
<b class="APPLICATION">LPRng</b> gets the printcap information.
Put the following lines in the <tt class=
"FILENAME">/etc/printcap</tt> file:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3126" id="AEN3126"></a>
<pre class="SCREEN">
# client entry
lp:tc=.client
lp2:tc=.client
.client:
:lp=%P@localhost
:force_localhost
lp:server
:cm=The Main Print Queue
:lp=/tmp/lp
:tc=.common
lp2:server
:cm=The Second Print Queue
:lp=/tmp/lp2
:tc=.common
.common:
:sd=/var/spool/lpd/%P
:mx=0
</pre>
</div>The <tt class="COMMAND">lpc client</tt> command is very
useful to see how <b class="APPLICATION">LPRng</b> uses this
printcap information:
<div class="INFORMALEXAMPLE">
<a name="AEN3130" id="AEN3130"></a>
<pre class="SCREEN">
<samp class="PROMPT">h4: {214} % </samp><kbd class=
"USERINPUT">lpc client</kbd>
Config
<samp class="PROMPT">h4: {215} % </samp><kbd class=
"USERINPUT">lpc client all</kbd>
Config
:lpd_port=2000
:printcap_path=/var/tmp/LPD/printcap
Names
:.client=.client
:.common=.common
:lp=lp
:lp2=lp2
:main=lp
All
:lp
:lp2
Printcap Information
lp|main
:force_localhost
:lp=lp@localhost
lp2
:force_localhost
:lp=lp2@localhost
</pre>
</div>
<p>The <tt class="COMMAND">lpc client all</tt> command shows
all of the configuration and printcap information, and is the
handiest one for system debugging and diagnostics. The
<span class="emphasis"><i class="EMPHASIS">Name</i></span>
information is the names of the printcap entries that have been
found in the database and is listed in sorted order. The
<span class="emphasis"><i class="EMPHASIS">All</i></span> are
entries that correspond to actual queues or printers and are
listed in the order that they appear in the printcap or
according to an order specified by the system administrator.
(See the <a href="printcappath.htm#ALLPC"><tt class=
"LITERAL">all</tt> Printcap Entry</a> for details.)</p>
<div class="SECT2">
<h2 class="SECT2"><a name="AEN3142" id="AEN3142">4.11.1.
Printcap Processing Format</a></h2>
<p>Queue or printer names must start with an alphanumeric
character, and contain only alphanumerics, hyphens
(<tt class="LITERAL">-</tt>) and underscores (<tt class=
"LITERAL">_</tt>). To avoid known and nasty problems with
sending and receiving print jobs from case sensitive and case
insensitive systems, <b class="APPLICATION">LPRng</b>
brutally lowercases all printcap entry names and printer
names.</p>
<p>The printcap file is processed by reading it line by line
and composing the individual printcap entries. Each entry has
an name and one or more aliases. The entries in the printcap
assign values to options. These can have the format:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3149" id="AEN3149"></a>
<pre class="SCREEN">
option=string value \n with escapes
flag # equivalent to flag=1
flag@ # equivalent to flag=0
option#value # equivalent to option=value
</pre>
</div>
<p>An option will have the last value that occurs in the
printcap entry.</p>
<p>Our example shows the use of the <tt class=
"LITERAL">tc</tt> (<span class="emphasis"><i class=
"EMPHASIS">t</i></span>ermcap in<span class=
"emphasis"><i class="EMPHASIS">c</i></span>lude) facility.
The <tt class="LITERAL">:tc</tt> value is a list of printcap
entries that should be prefixed to the <span class=
"emphasis"><i class="EMPHASIS">start</i></span> of the
printcap entry in which it appears. This allows options to be
set in the printcap entry which will override the values in
the <tt class="LITERAL">:tc</tt> included entry. For
convenience, the options are displayed in sorted order.</p>
<p>The <b class="APPLICATION">LPRng</b> clients and <b class=
"APPLICATION">lpd</b> server may require a different set of
options for the same spool queue. The clients require options
whose values tell the clients how the contact the <b class=
"APPLICATION">lpd</b> server and transfer a print job or
query to it. The <b class="APPLICATION">lpd</b> server needs
options that tell it how to either print a job or forward it
to another <b class="APPLICATION">lpd</b> server. The
<tt class="LITERAL">:client</tt> or <tt class=
"LITERAL">:server</tt> option marks a printcap entry as for
client or <b class="APPLICATION">lpd</b> server use only;
unmarked entries are used by both server and client. The
<tt class="COMMAND">lpc client</tt> command shows the
printcap information that the <b class=
"APPLICATION">LPRng</b> clients would use. For example, here
is what the <b class="APPLICATION">lpd</b> server would
use:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3171" id="AEN3171"></a>
<pre class="SCREEN">
<samp class="PROMPT">h4: {216} % </samp><kbd class=
"USERINPUT">lpc server all</kbd>
Config
:lpd_port=2000
:printcap_path=/var/tmp/LPD/printcap
Names
:.client=.client
:.common=.common
:lp=lp
:lp2=lp2
:main=lp
All
:lp
:lp2
Printcap Information
lp|main
:cm=The Main Print Queue
:force_localhost
:lp=/tmp/lp
:mx=0
:sd=/var/spool/lpd/%P
:server
lp2
:cm=The Second Print Queue
:force_localhost
:lp=/tmp/lp2
:mx=0
:sd=/var/spool/lpd/%P
:server
</pre>
</div>
<p>When we select the <tt class="LITERAL">server</tt>
printcap information, we see that the <tt class=
"LITERAL">:sd</tt> option has been added, and the <tt class=
"LITERAL">:lp</tt> replaced with new values.</p>
<p>We can use the <tt class="LITERAL">:oh</tt> (<tt class=
"LITERAL">o</tt>n this <tt class="LITERAL">h</tt>ost) option
to mark printcap entries for use by a selected set of hosts.
For example:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3183" id="AEN3183"></a>
<pre class="SCREEN">
lp:oh=10.0.0.0/255.255.255.0,*.private,!10.0.0.10
:lp=%P@10.0.0.10
</pre>
</div>
<p>The <tt class="LITERAL">:oh</tt> option takes a list of IP
addresses and masks or glob patterns, and applies these to
the IP addresses or list of Fully Qualified Domain Names for
the current host. If there is a for at least one IP address
or pattern in the list match then the entry is used. An
exclamation mark (<tt class="LITERAL">!</tt>) inverts the
sense of the match, and the entry is used if the match
fails.</p>
<p>Finally, we can use the <tt class="LITERAL">wildcard</tt>
facility to cause a default printcap entry to be used:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3190" id="AEN3190"></a>
<pre class="SCREEN">
lp|*:cm=Wildcard Alias - %P=lp, %Q=wanted
:lp=%P@10.0.0.10
*:cm=Wildcard Name- %P=wanted, %Q=wanted
:lp=%P@10.0.0.10
</pre>
</div>
<p>The <b class="APPLICATION">LPRng</b> software first
searches the printcap information for an exact match. If none
is found then it searches for the first wildcard entry that
matches the printer name. If the wildcard is used as an
alias, then the printcap entry is simply selected for use,
with the printer name and queue name selected as shown above.
We can also use partial matching as well:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3194" id="AEN3194"></a>
<pre class="SCREEN">
lp|lp_*
:lp=%P@10.0.0.10
qt|qt_*
:lp=%P@10.0.0.12
</pre>
</div>
<p>In the example above the first entry matches <tt class=
"LITERAL">lp</tt> and all printer names starting with
<tt class="LITERAL">lp_</tt>, while the second entry matches
<tt class="LITERAL">qt</tt> and all printer names starting
with <tt class="LITERAL">qt_</tt>. This can be useful when
setting up a family of spool queues as discussed in later
sections.</p>
</div>
<div class="SECT2">
<h2 class="SECT2"><a name="AEN3201" id="AEN3201">4.11.2.
Printcap Information From Programs and Databases</a></h2>
<p>There many administrators store system information on a
database server and having programs or utilities get their
configuration information from this server. The use of the
database allows easier system administration and also
centralizes the administration. Rather than build in the
various types of database access, the LPRng software allows
the use of programs to obtain printcap information. This not
only allows any type of database to be used, but also removes
any legal or license restrictions on the redistribution of
the actual software.</p>
<p>We will use very simple example to show how you can use a
program to get printcap information. First, you must
configure the <b class="APPLICATION">LPRng</b> software to
use a program to get the filter information. This is done by
setting a value in the <tt class="FILENAME">lpc.conf</tt>
file (usually <tt class="FILENAME">/etc/lpd.conf</tt> or
<tt class="FILENAME">/usr/local/etc/lpd.conf</tt>). Copy your
<tt class="FILENAME">lpd.conf</tt> file to <tt class=
"FILENAME">lpd.conf.bak</tt> and then add the following line
to the end of the file:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3211" id="AEN3211"></a>
<pre class="SCREEN">
printcap_path=|/tmp/getpc
<samp class="PROMPT">h4: {217} % </samp><kbd class=
"USERINPUT">cd /etc</kbd>
<samp class="PROMPT">h4: {218} % </samp><kbd class=
"USERINPUT">cp lpd.conf lpd.conf.bak</kbd>
<samp class="PROMPT">h4: {219} % </samp><kbd class=
"USERINPUT">echo 'printcap_path=|/tmp/getpc' >>lpd.conf</kbd>
</pre>
</div>
<p>Next, edit the <tt class="FILENAME">/tmp/getpc</tt> file
and set its values as shown below.</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3221" id="AEN3221"></a>
<pre class="SCREEN">
set /tmp/getpc:
#!/bin/sh
# /tmp/getpc
echo PROG $0 "$@" >>/tmp/trace
cat >>/tmp/trace
cat <<EOF
lp:lp=test@host
EOF
exit 0
<samp class="PROMPT">h4: {220} % </samp><kbd class=
"USERINPUT">chmod 755 /tmp/getpc</kbd>
<samp class="PROMPT">h4: {221} % </samp><kbd class=
"USERINPUT">echo testing | /tmp/getpc -aoption</kbd>
lp:lp=test@host
<samp class="PROMPT">h4: {222} % </samp><kbd class=
"USERINPUT">cat /tmp/trace</kbd>
PROG /tmp/getpc -aoption
testing
</pre>
</div>
<p>After you have tested the <b class="APPLICATION">getpc</b>
script, use the <tt class="COMMAND">lpc client all</tt>
command:</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3232" id="AEN3232"></a>
<pre class="SCREEN">
<samp class="PROMPT">h4: {223} % </samp><kbd class=
"USERINPUT">lpc client all</kbd>
Config
:lockfile=/var/tmp/LPD/lpd
:lpd_port=2000
:printcap_path=|/tmp/getpc
Names
:lp=lp
All
:lp
Printcap Information
lp
:lp=test@host
<samp class="PROMPT">h4: {224} % </samp><kbd class=
"USERINPUT">cat /tmp/trace</kbd>
<samp class="PROMPT">h4: {225} % </samp><kbd class=
"USERINPUT">cat /tmp/trace</kbd>
PROG /tmp/getpc -Pall -aacct -l66 -sstatus \
-t2000-05-05-08:40:51.000 -w80 -x0 -y0 acct
all
PROG /tmp/getpc -Pall -aacct -l66 -sstatus \
-t2000-05-05-08:40:51.000 -w80 -x0 -y0 acct
*
</pre>
</div>
<p>As seen from the <tt class="FILENAME">/tmp/trace</tt>
file, the <tt class="COMMAND">getpc</tt> program is invoked
with the standard filter parameters. The <tt class=
"LITERAL">-P</tt> command line literal is set to the name of
the printcap entry and the name of the entry is written to
the filter's <acronym class="ACRONYM">STDIN</acronym>. If the
entry is not found, then the wildcard printcap entry will be
requested. The <tt class="LITERAL">-P</tt> literal is
<span class="emphasis"><i class="EMPHASIS">not</i></span> set
to <tt class="LITERAL">*</tt>, as this has the possibility of
opening a security loophole when a shell script parses the
filter's command line options.</p>
<p>You restore the original <tt class=
"FILENAME">lpd.conf</tt> file to restore the system to normal
operation.</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3250" id="AEN3250"></a>
<pre class="SCREEN">
<samp class="PROMPT">h4: {226} % </samp><kbd class=
"USERINPUT">cd /etc</kbd>
<samp class="PROMPT">h4: {227} % </samp><kbd class=
"USERINPUT">cp lpd.conf.bak lpd.conf</kbd>
</pre>
</div>
<p>When using the program method to return information,
special consideration should be given to the <tt class=
"LITERAL">all</tt> request. If there is not an explicit
<tt class="LITERAL">all</tt> entry, then the program should
take appropriate steps to enumerate the values in the
database, or report that there is a missing <tt class=
"LITERAL">all</tt> entry to the appropriate administrative
authority.</p>
</div>
<div class="SECT2">
<h2 class="SECT2"><a name="AEN3260" id="AEN3260">4.11.3. User
Printcap Information</a></h2>
<p>In addition to the system printcap, each user can define a
private printcap file that will be read after the system
printcap. Users can define <b class="APPLICATION">LPRng</b>
client entries and can augment the system printcap
information.</p>
<p>By default, <tt class="FILENAME">${HOME}/.printcap</tt> is
the the user printcap file. Here is a simple example of a
user printcap file.</p>
<div class="INFORMALEXAMPLE">
<a name="AEN3266" id="AEN3266"></a>
<pre class="SCREEN">
# remote printer - default
lp:lp=raw@localhost
:ifhp=model=laserjet4
:filter=/usr/local/libexec/filters/ifhp
# direct connection to printer over TCP/IP connection
lp:lp=10.0.0.5%9100
:direct
:ifhp=model=phaser
:filter=/usr/local/libexec/filters/ifhp
</pre>
</div>
<p>The two examples show how a simple printer definition can
be created. The first example shows how to create a simple
way to send a file directly to a remote print queue after
passing it through a filter. This is usually called
<span class="emphasis"><i class="EMPHASIS">client
side</i></span> filtering.</p>
<p>The second example is more interesting. Here we do the
same thing, but we open a connection to the remote port on a
host and send the print job. We do not spool the print job
but send it directly. This is called <span class=
"emphasis"><i class="EMPHASIS">lightweight lpr</i></span>
printing.</p>
<p>While the user printcap file is read after the system
printcap file, the order of printcap entries is modified so
that any entries that appeared in the user printcap file will
appear before entries in the system printcap file. This
allows users to modify the order in which printer entries are
displayed.</p>
</div>
</div>
<div class="NAVFOOTER">
<hr align="left" width="100%">
<table summary="Footer navigation table" width="100%" border=
"0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href=
"jobfileformatconversion.htm" accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href=
"index.htm" accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href=
"x3273.htm" accesskey="N">Next</a></td>
</tr>
<tr>
<td width="33%" align="left" valign="top">Job File Format
Conversion with Filters</td>
<td width="34%" align="center" valign="top"><a href=
"tutorial.htm" accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Banner Printing
and the OF filter</td>
</tr>
</table>
</div>
<p align="center"></p>
</body>
</html>
|