📄 00000005.htm
字号:
This is line three. <BR> <BR> 若将 PostScript 的档送往这个 spool, 将得到很漂漂的, 楼梯状但无用的输出. <BR> 很显然的, 我们需要更多的设定, 这就是过滤(filtering)的目的. 如果你有仔细 <BR>地看 printcap 的 man page 的话, 你应该注意到了 spool 的 if 和 of 属性 ! <BR> 嗯, if 属性(或说是输入过滤器) 就是我们要的啦 ! <BR> <BR> 如果我们要写一个在新一行前加入换行符号的 shell script, 以消除楼梯形状的 <BR>话, 我们可以在 printcap 中加入 if 如下: <BR> <BR> lp|dj|deskjet:\ <BR> :sd=/var/spool/lpd/dj:\ <BR> :mx#0:\ <BR> :lp=/dev/lp0:\ <BR> :if=/var/spool/lpd/dj/filter:\ <BR> :sh: <BR> <BR> 一个简单的过滤 script 如下: <BR> <BR> #!perl <BR> while(<STDIN>){printf "$_\r";}; <BR> <BR> 如果我们照上面做了以後, 就可以正常列印一般的 unix text 档了.(有4千万个 <BR>方式可写出更好的过滤器, 但太难去举例了, 你不妨自己去试著写写看) <BR> <BR> 但问题是只能印文字档真是不爽, 最好是可以出 PostScript 或其它格式, 甚至 <BR>图形才能满足我. 那好吧, 其实也很简单, 在上面的方法再加上延伸的 linefeed- <BR>fixing filter 就行了. 如果你能写一个可接受任何档案格式输入, 并可由 DeskJet <BR>正常输出的 script, 那麽你的确是一个聪明的 spooler ! <BR> <BR> 像这种 filter 叫做 magic filter. 这并不困难, 除非你真的要印很怪的东东. 因 <BR>为网路上已经有人帮你写好罗 ! <BR> <BR> <BR> 5.2 File Permissions 档案权限 <BR> <BR> 我开了张表以列出在我自己系统上一些有趣的档案及其权限. 理论上最好只 <BR>要用到 SGID 而不要用 SUID, 有一狗票的方式可做到, 但我的系统将真实情 <BR>形揭露如下(Quite frankly, if your vendor can't even ship a working lpd you're <BR>in for a rough ride): <BR> <BR> -r-sr-sr-x 1 root lp /usr/bin/lpr* <BR> -r-sr-sr-x 1 root lp /usr/bin/lprm* <BR> -rwxr--r-- 1 root root /usr/sbin/lpd* <BR> -r-xr-sr-x 1 root lp /usr/sbin/lpc* <BR> drwxrwxr-x 4 root lp /var/spool/lpd/ <BR> drwxr-xr-x 2 root lp /var/spool/lpd/lp/ <BR> <BR> Lpd 目前是以 root 的身份在 run, 也就是如此它才可以使用低号码的服务埠 <BR>(service port). 看起来它好像可以在 binding 之後变成 lp.lp 之类的 UID, 可是 <BR>我想这是行不通的, 真令人失望. <BR> <BR> <BR> <BR>6. How to obtain an appropriate magic filter 如何获得一个适当的 magic filter <BR> <BR> 6.1 APS Filter <BR> <BR> Andreas Klemm 的 aps filter 是最好的 magic tilter 其中之一, The Linux <BR>Software Map entry goes something like this: <BR> <BR> Begin3 <BR> Title: apsfilter <BR> Version: 4.9.1 <BR> Entered-date: Montag, 10. Juli 1995, 21:22:35 Uhr MET DST <BR> Description: magicfilter for lpd with auto filetype detection <BR> Keywords: lpd magicfilter aps apsfilter <BR> Author: <A HREF="mailto:andreas@knobel.GUN.de">andreas@knobel.GUN.de</A> (Andreas Klemm) <BR> Maintained-by: <A HREF="mailto:sledge@hammer.oche.de">sledge@hammer.oche.de</A> (Thomas Bueschgens) <BR> <A HREF="mailto:andreas@knobel.GUN.de">andreas@knobel.GUN.de</A> (Andreas Klemm) <BR> Primary-site: sunsite.unc.edu <BR> /pub/Linux/system/Printing/ <BR> 211KB aps-491.tgz <BR> Original-site: ftp-i2.informatik.rwth-aachen.de <BR> /pub/Linux/pak/APSfilter/aps-491.tgz <BR> Platforms: C-Compiler, gs Postscript emulator, pbmutils <BR> Copying-policy: GPL <BR> End <BR> <BR>APS filter 为列表伫列为了一个 if filter, 使你的印表机指令集可以解译很多 <BR>常见的档案格式. 例如: text, PostScript, dvi, gif, and others. <BR> <BR> 6.2 Magic-filter <BR> <BR> B.A.McCawley 的 magic-filter package 做的事与 APSfilter 很像, 但它是用 <BR>bash 写的, 你可能比较容易把它改成适合你用的.The LSM entry: <BR> <BR> Version: 0.4 <BR> Description: Bash scripts to simplify the task of configuring lpd to <BR> auto-detect file types using /etc/magic. (As advertised in the <BR> printing-HOWTO). <BR> This package uses existing filters so it only prints file types for <BR> which one already has filters (or compressed versions <BR> thereof). Alterative magic filter approches are described in the <BR> printing-HOWTO. <BR> Keywords: lpd, /etc/magic, printing, filter <BR> Author: <A HREF="mailto:B.A.McCauley@bham.ac.uk">B.A.McCauley@bham.ac.uk</A> (Brian McCauley) <BR> Maintained-by: <A HREF="mailto:B.A.McCauley@bham.ac.uk">B.A.McCauley@bham.ac.uk</A> <BR> Primary-site: tsx-11.mit.edu pub/linux/sources/usr.bin <BR> magic-filter-0.4.tar.gz 5709 <BR> Copying-policy: GNU GPL <BR> <BR> <BR> <BR>7. Serial printers under lpd lpd 下的序列印表机 <BR> <BR> 7.1 Setting up in printcap <BR> <BR> Lpd 在 /etc/printcap 中提供了 5 个属性让你控制序列印表机的设定. 看看 <BR>printcap man page 中关於 br#, fc#, xc#, fs#, xs# 的部分. The last four of these <BR>attributes are bitmaps indicating the settings for use the port. br# 属性控制 <BR>baud rate, 例: `br#9600'. <BR> <BR> 将 stty 的设定转成 printcap flag 的设定很容易, 如果你有需要的话, 请看 <BR>stty 的 man page. <BR> 利用 stty 来设定印表机埠的方式, 现在我们可以用 cat 来将档案印出. 下面 <BR>是我用 'stty -a' 所显 示我的印表机埠的状态: <BR> <BR> dina:/usr/users/andy/work/lpd/lpd# stty -a < /dev/ttyS2 <BR> speed 9600 baud; rows 0; columns 0; line = 0; <BR> intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; <BR> eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; <BR> lnext = ^V; min = 1; time = 0; <BR> -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts <BR> -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr <BR> -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel <BR> -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 <BR> bs0 vt0 ff0 <BR> -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase <BR> -tostop -echoprt -echoctl -echoke <BR> <BR> 和开机时 initialized 的方式不同的地方仅在 -clocal, -crtscts, 和 ixon. 你的埠 <BR>可能和我的不太一样, 端看你的印表机用什麽样的 flow control 而定. <BR> <BR> 现在你已设好你的 stty 了, 在我的状态下, 我用 'cat file > /dev/ttyS2' 将档案 <BR>送到印表机. 看一下 /usr/src/linux/include/linux/termios.h, 这里面包含了一些 <BR>#defines 和 structs(你该将此档印出来 (你正如此做, 对吧?)看看), 请找到下面 <BR>这一段: <BR> <BR> /* c_cflag bit meaning */ <BR> #define CBAUD 0000017 <BR> <BR> This section lists the meaning of the fc# and fs# bits. You will notice that <BR>the names there (after the baud rates) match up with one of the lines of stty <BR>output. Didn't I say this was going to be easy? <BR> <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -