プリンタの設定
目的 lprng, を用いてネットワークプリンタへ出力する.
必要パッケージ lrng, lprng-doc, lprngtool enscript magicfilter
参考資料
概要 ネットワーク上の ps プリンタを使える環境を整える. また magickfilter を利用することで, ファイル形式を意識せずに lpr コマンドがつかえるようになる.
  1. 必要パッケージのインストール
  2. プリンタの設定.
  3. 動作確認
  1. 必要パッケージのインストール
    # apt-get install lprng lprng-doc lprngtool

    上記コマンドを実行すると boot 時に lpd を起動するか 聞いて来るので Yes とした.

    # apt-get install magicfilter
    
  2. プリンタの設定.

    普段は printcap を直に編集しているのだが 今回は magicfilter なるものを使ってみる. 各種フィルタを簡単にかますことができるらしい.

    # magicfilterconfig 
    You will have to supply the following items for each printer to be installed
    (example values in parentheses):
    
     - its short name and its full name            (hpjlet4, HP LaserJet 4)
     - the device where the printer is attached    (/dev/lp0)
     - and the input filter you want to use        (ljet4l)
    
    Printer #1:
    ------------
    Full name, `done' when done                   [HP Laserjet 4L ]:  hogepr
    Short name, name of the spool directory       [hplj4l         ]:  hogepr-spool
    Full device path (or remote machine name)     [/dev/lp1       ]:  133.87.**.**
    
    The following filters are available in /etc/magicfilter.
    
    You can read the comments at the top of each file to help decide which
    filter would best suit your needs.
    
    The filters concentrate on the printer language. If you know, that your
    printer uses a given printer language (e.g. ESC/P2 or PCL5) and your
    printer is not listed below, you can use another filter which uses same
    language.
    
    Read the file `/usr/share/doc/gs/Devices.htm' from the GhostScript package
    and have your printer manual handy if you want to change a filter.
    
    StylusColor-1520@1440dpi StylusColor-500@360dpi 
    StylusColor-500@720dpi StylusColor-600@1440dpi StylusColor-600@360dpi 
    StylusColor-600@720dpi StylusColor-800@1440dpi StylusColor-800@360dpi 
    StylusColor-800@720dpi StylusColor-II-IIs@360dpi StylusColor-II@720dpi 
    StylusColor-IIs@720dpi StylusColor-generic StylusColor@360dpi 
    StylusColor@720dpi bj10e bj200 bj600 bj600_draft bj610 bj800 bj800_draft cps300 
    cps400 cps600 cpsonly300 cpsonly400 cpsonly600 deskjet dj500 dj500c 
    dj550c dj630c dj670c dj670c-best dj670c-low dj690c dj690c-best 
    dj690c-low e312 epson9 epson9c epsonlq epsonlqc gdi ibmpro jetp3852 la50 la75 
    laserjet laserjetlo lbp8 lj250 ljet2p ljet2plo ljet3 ljet4 ljet4050 ljet4l 
    ljet4m ljet4ml ljetplus ljetpluslo ln03 m8510 necp6 oki182 pcl3 pj pjxl 
    pjxl300 ps300 ps400 ps600 psonly300 psonly400 psonly600 r4081 
    stylus800 tek4693 tek4696 
    
    The input filter to be used                   [ljet4l         ]: ps600
    
    Printer #2:
    ------------
    Full name, `done' when done                   [done           ]: _
    

    以上の様にして必要なエントリを加え, 終了したら done を入力.

    Printer name  Short name Spool dir            Device     Input filter
    -------------------------------------------------------------------------------
    hogepr        hogepr-spo /var/spool/lpd/hogep            ps600              R*
    heropr        heropr-spo /var/spool/lpd/herop            ps600              R
    neropr        neropr-spo /var/spool/lpd/nerop            cps600             R
    
    Do you want to change the default printer? (y/n) [n]: n
    Is this ok? (y/n) [y]: y
    
    Paper size is A4, page length is 72 lines.
    /var/tmp/printcap generated.
    
    You'll probably want to finetune your newly created /var/tmp/printcap file.
    Read the printcap(5), lpr(1), lpq(1), lprm(1) and lpc(1) manual pages
    and the PRINTING-HOWTO before doing this.
    
    Since Debian policy forbids overwriting another package's configuration files
    (/etc/printcap belongs to the lpr* packages) you have to install the newly
    generated /var/tmp/printcap by hand:
    
      1. Stop the running lpr:
      #/etc/init.d/lpr stop  || /etc/init.d/lprng stop
      2. Save the old printcap:
      #mv /etc/printcap /etc/printcap.orig
      3. Install magicfilter's printcap:
      #mv /var/tmp/printcap /etc/printcap
      4. Start lpr:
      #/etc/init.d/lpr start || /etc/init.d/lprng start
    

    表示されたように /var/tmp に作成された printcap を /etc/ に移動する.

    root@pygo:~# /etc/init.d/lprng stop
    Stopping printer spooler: lprng.
    root@pygo:~# mv /etc/printcap /etc/printcap.original
    root@pygo:~# mv /var/tmp/printcap  /etc/printcap          
    

    ここで printcap を見てみると, "Short name" が rp 等のエントリに使われていることが分かる. 必要に応じて rp エントリを書き換える.

    root@pygo:~# /etc/init.d/lprng start
    Starting printer spooler: lprng
    

  3. 動作確認

    万が一の場合を考え, 小さな ps ファイルを作成し, プリンタに送ってみる.

    $ ls -l  test.ps 
    -rw-r--r--    1 mym      mym           572  8月 14 14:20 test.ps
    $ lpr -Phogepr test.ps
    $ lpq -Phogepr
    Printer: hogepr-spool@pygo 'hogepr' (dest hogepr-spool@133.87.**.**)
     Queue: no printable jobs in queue
     Server: no server active
     Status: job 'mym@pygo+309' removed at 14:36:06.475
     Rank   Owner/ID                  Class Job Files                 Size Time
    done   mym@pygo+8                   A     8 test.ps                572 14:08:01
    no entries 
    

    うまくいったら, magickfilter のためしに png などを送ってみる.


mym@ep.sci.hokudai.ac.jp