📄 ch20.htm
字号:
<PRE><FONT COLOR="#0066FF">mkdir /usr/spool/lpd /usr/spool/lpd/foobar
chown root.daemon /usr/spool/lpd /usr/spool/lpd/foobar
chmod ug=rwx,o=rx /usr/spool/lpd /usr/spool/lpd/foobar
</FONT></PRE>
<DL>
<DD><B>2. </B>In the directory <TT>/usr/spool/lpd/foobar</TT>, create the necessary
files and give them the correct permissions and owner:<FONT COLOR="#0066FF"></FONT>
</DL>
<PRE><FONT COLOR="#0066FF">cd /usr/spool/lpd/foobar
touch .seq errs status lock
chown root.daemon .seq errs status lock
chmod ug=rw,o=r .seq errs status lock
</FONT></PRE>
<DL>
<DD><B>3.</B> Create the shell script <TT>input_filter</TT> in the directory <TT>/usr/spool/lpd/foobar</TT>.
You can have this as an empty file, too. Just be sure that the file is owned by <TT>root</TT>,
group daemon, and is executable by anyone.<FONT COLOR="#0066FF"></FONT>
</DL>
<PRE><FONT COLOR="#0066FF">cd /usr/spool/lpd/foobar
chmod ug=rwx,o=rx input_filter
</FONT></PRE>
<DL>
<DD><B>4.</B> Create the file <TT>/etc/printcap</TT> if it doesn't already exist.
Remove all entries in it and add the test printcap entry given in Listing 20.1. Make
sure the file is owned by <TT>root</TT>, and read-only to everyone else (<TT>-rw-r-r-</TT>).
</DL>
<CENTER>
<H3><A NAME="Heading10<FONT COLOR="#000077">Listing 20.1. A sample /etc/printcap
file.</FONT></H3>
</CENTER>
<PRE><FONT COLOR="#0066FF">
#
# Copyright (c) 1983 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that this notice is preserved and that due credit is given
# to the University of California at Berkeley. The name of the University
# may not be used to endorse or promote products derived from this
# software without specific prior written permission. This software
# is provided "as is" without express or implied warranty.
#
# @(#)etc.printcap 5.2 (Berkeley) 5/5/88
#
# DecWriter over a tty line.
#lp|ap|arpa|ucbarpa|LA-180 DecWriter III:\
# :br#1200:fs#06320:tr=\f:of=/usr/lib/lpf:lf=/usr/adm/lpd-errs:
#lp:lp=/dev/lp0:sd=/usr/spool/lp0:of=/usr/lib/lpf: lf=/usr/adm/lpd-errs
#
# Generic printer:
lp:lp=/dev/lp1:sd=/usr/spool/lp1:sh
#
# typical remote printer entry
#ucbvax|vax|vx|ucbvax line printer:\
# :lp=:rm=ucbvax:sd=/usr/spool/vaxlpd:lf=/usr/adm/lpd-errs:
#varian|va|Benson Varian:\
# :lp=/dev/va0:sd=/usr/spool/vad:mx#2000:pl#58:px#2112:py#1700:tr=\f:\
# :of=/usr/lib/vpf:if=/usr/lib/vpf:tf=/usr/lib/rvcat:cf=/usr/lib/vdmp:\
# :gf=/usr/lib/vplotf:df=/usr/local/dvif:\
# :vf=/usr/lib/vpltdmp:lf=/usr/adm/lpd-errs:
#versatec|vp|Versatec plotter:\
# :lp=/dev/vp0:sd=/usr/spool/vpd:sb:sf:mx#0:pw#106:pl#86:px#7040:py#2400:\
# :of=/usr/lib/vpfW:if=/usr/lib/vpsf:tf=/usr/lib/vcat:cf=/usr/lib/vdmp:\
# :gf=/usr/lib/vplotf:vf=/usr/lib/vpltdmp:lf=/usr/adm/lpd-errs:\
# :tr=\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n:
#
#lp|panasonic:lp=/dev/lp1:sd=/usr/spool/lp/panasonic:lf=/usr/bin/mail:mc#1:\
# ft=$$c$$p$$r$$f:hl#2:fl#3:ht=$$c$$n$$r$$t:sh:
#
# HP Laser jet plus
#lp|hpj:\
# :lp=/dev/lp1:\
# :sd=/usr/spool/lp1:\
# :mx#0:\
# :of=/usr/spool/lp1/hpjlp:
# :lf=/usr/spool/lp1/hp-log:
#
#lp|Generic dot-matrix printer entry:\
# :lp=/dev/lp1:\
# :sd=/var/spool/lp1/lp:sh:\
# :if=/usr/bin/lpf:\
# :df=/var/spool/lp1/filter.ps:\
# :tf=/var/spool/lp1/filter.ps:\
# :af=/var/spool/lp1/lp-acct:\
# :lf=/var/spool/lp1/lp-err:
</FONT></PRE>
<DL>
<DD><B>5. </B>Start the <TT>lp</TT> daemon with the <TT>lpd</TT> command.<BR>
<B><BR>
6.</B> Do a test print using the command:<FONT COLOR="#0066FF"></FONT>
</DL>
<PRE><FONT COLOR="#0066FF">ls -l | lpr -Pmyprinter
</FONT></PRE>
<P>You can restrict remote users by group name by specifying the groups permitted,
using one or more <TT>rg</TT> fields; for example, <TT>/etc/printcap - :rg=admin</TT>:
restricts access to a printer to those users belonging to the group admin. You can
also restrict access to those users with accounts on your system, by specifying the
boolean flag <TT>:rs:</TT> in your <TT>/etc/printcap</TT>.
<CENTER>
<H4><A NAME="Heading11<FONT COLOR="#000077">The Staircase Effect</FONT></H4>
</CENTER>
<P>The staircase effect results in lines printed one after another, with each line
beginning where that last one ended. Usually, the output results in a few lines on
the first page followed by many blank pages. An example of such an output is as follows:
<BR>
<BR>
one</P>
<P>two</P>
<P>three<BR>
<BR>
four<BR>
<BR>
<BR>
Linux terminates each line of a file with a linefeed but not a carriage return. Therefore,
the physical printing device should start each line below the end of the previous
line. Some printers can be set to treat "linefeed" as "carriage return,
linefeed," others cannot be set this way. If your printer can be set to treat
"linefeed" as "carriage return, linefeed," then do that. If the
printer cannot be modified, you should create a shell script filter that reads like
this:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">#!/bin/sh
if [ "$1" = -c ]; then
cat
else
sed -e s/$/^M/
fi
# the "echo -ne" assumes that /bin/sh is really bash
</FONT></PRE>
<PRE><FONT COLOR="#0066FF">echo -ne \\f
</FONT></PRE>
<P>Install this filter as the <TT>if</TT> filter by putting <TT>:if=/usr/lib/lpf:</TT>
(or whatever) in your <TT>/etc/printcap</TT> entry for the printer.</P>
<P>Magic filters deduce their input files types from "magic numbers," which
is a distinctive byte pattern at particular offsets. Magic filters are usually Perl
scripts, Shell scripts, or C programs that simply identify the file type and then
call the appropriate non-magic filter. A magic filter usage example is the "file"
command which tries to interpret the type of file by reading the first few bytes.
<CENTER>
<H3><A NAME="Heading12<FONT COLOR="#000077">PostScript Support</FONT></H3>
</CENTER>
<P>The Linux and UNIX community is completely PostScript dependent when it comes
to documentation. If you don't have PostScript printing capability in your printer,
there are times when you cannot even read documentation for software packages.</P>
<P>If you have access to a PostScript printer, no problem. Print all you want. On
the other hand, if you want to save paper or do not have access to a PostScript printer,
consider using Ghostscript. See Chapter 25, "Ghostscript," for more information
about installing and using Ghostscript. In a nutshell, Ghostscript, which comes from
the GNU project, is a PostScript interpreter that accepts PostScript input and generates
output appropriate for X displays, printers, and some specialized display hardware
and fax software.</P>
<P>There are a number of utilities that enable text to be printed to a PostScript
device.
<UL>
<LI><TT>a2ps</TT>. This utility takes text and turns it into a PostScript document
with headers and footers and page numbers. You can even print two pages on one sheet
of paper.
<P>
<LI><TT>nenscript</TT>. The <TT>nenscript</TT> program is a clone of a commercial
<TT>enscript</TT> program. The functionality is the same as that of <TT>a2ps</TT>.
<P>
<LI><TT>gslp</TT>. This is a PostScript program that comes with Ghostscript and is
used to print a preamble to text files to convert the text files into PostScript.
Check the man pages for <TT>gslp.ps</TT>.
</UL>
<CENTER>
<H4><A NAME="Heading13<FONT COLOR="#000077">Printing DVI Files</FONT></H4>
</CENTER>
<P>A DVI file is the processed output from a <TT>LaTeX</TT> or <TT>TeX</TT> input
file. To print a DVI file to a PostScript printer, you can use <TT>dvips</TT> or
<TT>eps</TT>. The <TT>dvips</TT> program converts DVI into PostScript. The output
can be piped into Ghostscript or sent directly via <TT>lpr</TT> to a PostScript printer.
<TT>eps</TT> is a program which converts DVI files directly into the standard Epson
printer language. It is a DVI driver for Epson printers.
<CENTER>
<H3><A NAME="Heading14<FONT COLOR="#000077">Summary</FONT></H3>
</CENTER>
<P>This chapter has given you a quick tour of the printing system under Linux. Armed
with the information in this chapter, you should be able to get printing to work
on your Linux machine.
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -