7. プリンタ・サーバの構築

さて今度は、プリンタ・サーバの構築である。これは、CAP と lpd の組み合わせで、ゾーン内の AppleTalk で繋がっている PostScript プリンタに自由にプリント・ジョブを送るというものである。さら に lpd のリモート機能を使えば、CAP がインストールされていない Unix Box からでも、CAP がインストールされている Linux Box 経由 でプリント・ジョブを PostScript プリンタに送ることができる。ま ず最初に atlooklws というコマンドで特定のゾーン の中で使用できる PostScript プリンタを一覧表示させてみよう。 以下のような出力が得られるはずだ。

  # atlooklws "hogehoge zone"

  abInit: [ddp:  15.160, 228], [GW:  15.160, 167] starting
  Looking for =:LaserWriter@SJ TW 8 ...
    1 - ATM Dev IIg:LaserWriter@*                [Net: 15.161 Node: 83 Skt:191]
  ---status: idle
  Address confirmed for socket 191
    2 - Apple LaserWriter IINTX_J:LaserWriter@*  [Net: 15.161 Node:221 Skt:169]
  ---status: idle
  Address confirmed for socket 169
    3 - Canon Lasershot B406GII_J:LaserWriter@*  [Net: 15.161 Node:202 Skt:128]
  ---status: idle
  Address confirmed for socket 128
    4 - Centaur (fonts LWII-NTX):LaserWriter@*   [Net: 15.161 Node:153 Skt:234]
  ---status: idle
  Address confirmed for socket 234
    5 - Cheque:LaserWriter@*                     [Net: 15.161 Node:167 Skt:191]
  ---status: idle
  Address confirmed for socket 191
    6 - EPSON LP-8200PS2:LaserWriter@*           [Net: 15.161 Node:172 Skt:128]
  ---status: idle

今度は、特定のプリンタにアクセスして、PostScript インタプリタを 起動させてみよう。それは、tlw というコマンドで行なう。

  # tlw "Canon Lasershot B406GII_J:LaserWriter@*"
  abInit: [ddp:  15.160, 228], [GW:  15.160, 167] starting
  Starting session with Canon Lasershot B406GII_J:LaserWriter@*
  %no status
  status: idle

  Okay
  PostScript(r) Version 2013.115
  (c) Copyright 1984-1994 Adobe Systems Incorporated.
  Typefaces (c) Copyright 1981 Linotype-Hell AG and/or its subsidiaries.
  All Rights Reserved.
  PS> showpage

次にこのプリンタに何か PS ファイルを送り、プリントしてみる。

  # lwpr -p "Canon Lasershot B406GII_J:LaserWriter@*" temp.ps
  abInit: [ddp:  15.160, 228], [GW:  15.160, 167] starting
  Status: status: idle
  status: idle
  Sending temp.ps

これで印刷が可能かどうか分かったら、次に lpd と連係して PostScript プリンタに AppleTalk を介してプリント・ジョブを送り、印刷させるた めの設定に入る。まず、/etc ディレクトリに cap.printers というゾーン内の PostScript プリンタ の名前を定義するファイルを以下のようにして作る。

  #
  # /etc/cap.printers
  #

  ntxj=Apple LaserWriter IINTX_J:LaserWriter@*
  canon=Canon Lasershot B406GII_J:LaserWriter@*
  # ---- End of /etc/cap.printers ----

次に printcap を環境に合わせて編集する。

  # /etc/printcap
  #
  # Please don't edit this file directly unless you know what you are doing!
  # Be warned that the control-panel printtool requires a very strict format!
  # Look at the printcap(5) man page for more info.
  #
  # This file can be edited with the printtool in the control-panel.

  ##PRINTTOOL## LOCAL PostScript 300x300 a4 1
  lp:\
          :sd=/var/spool/lpd/lp:\
          :lp=/dev/lp1:\
          :sh:\
          :mx#0:\
          :if=/var/spool/lpd/lp/filter:

  ## Remote PostScript Canon Laser Shot B-406G II
  lp|canon|Canon Lasershot B406GII_J:\
          :lp=/dev/canon:\
          :sd=/var/spool/lpd/canon:\
          :pl#72:pw#85:\
          :sf:\
          :mx#0:\
          :lf=/var/spool/lpd/canon/canon-lpd-errs:\
          :af=/var/spool/lpd/canon/canon-lpd-acct:\
          :if=/usr/local/cap/canonif:\
          :of=/usr/local/cap/papof:
  # ---- End of /etc/printcap ----

次に特定のプリンタに対するデバイス・ポートを作る。

  # touch /dev/canon
  # chmod 660 /dev/canon

次は、特定のプリンタに対するスプール・ディレクトリやバナー ・ファイルを作る。

  # mkdir /var/spool/lpd
  # mkdir /var/spool/lpd/canon
  # touch /var/spool/lpd/canon/.banner
  # chmod daemon.daemon /var/spool/lpd/canon/.banner

続いてログ・ファイルの作成である。

  # touch /var/spool/lpd/canon/canon-lpd-errs
  # touch /var/spool/lpd/canon/canon-lpd-acct

最後に特定のプリンタのためのフィルター・ファイルを以下のように して作る。

  #!/bin/sh
  # canonif - CAP Input filter for Canon Laser Shot B-406G II

  /usr/local/cap/papif -P canon $*
  # ---- End of /usr/local/cap/canonif ----

プリント・コマンドは、以下の通り:

  # lpr -Pcanon hogehoge.ps

さて次に CAP がインストールされていない Unix Box (hogehoge2)から CAP がインストールされてある Linux Box (hogehoge1)経由でプリント ・ジョブを printcap に登録してあるプリンタに 送るための設定方法について記す。まず CAP がインストールされてある Linux Box の /etc ディレクトリに hosts.lpd というファイルを以下のように作る。

  # hosts.lpd
  hogehoge2

さらに CAP がインストールされていない Unix Box の printcap を lpd のリモート機能が使えるように次のように設定する。

  # CAP がインストールされていない Unix Box の printcap
  lp|canon|:lp=:rm=hogehoge1:rp=canon:

こうすることで、hogehoge2 から次のコマンドで hogehoge1 にプリン ト・ジョブを送ることができる。

  # lpr -Pcanon hogehoge.ps