NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Printing to networked printers?



On Thu, 20 Jul 2017, jgw%sdf.org@localhost wrote:

I've been using a crusty old HPLJ PCL-only printer for years with
the following setup:

--
The following was done to enable traditional lpd-based printing on NetBSD:
(note: you'll need to install ghostscript for PostScript printing)

1) create /etc/printcap entry:

# sudoedit /etc/printcap
...
# HP Laserjet 2100 on HP JetDirect print server on LAN @ 192.168.1.12:
lp|hplj-2100:\
       :sh:\
       :sd=/var/spool/output/lpd/hplj-2100:\
       :rm=192.168.1.12:\
       :rp=PORT1:\
       :lf=/var/log/lpd-errs:\
       :lp=/dev/null:\
       :if=/usr/local/lib/if-hplj_2100:\
       :mx#0:

Hmmm. You're using :rm=192.168.1.12: and :rp=PORT1: rather than my use of :lp=9100@192.168.1.250: (and you're using the -r option on lpd to allow the use of an input filter on the remote printer). I understand what you're doing, but I'm pretty sure it's not related to my problems, as I have confirmed with tcpdump that I'm successfully sending data to the printer via port 9100. Just in case, I tried using rm&rp but still I get nothing printed. "lpc stat" shows that the job is still in the queue, "waiting for 192.168.1.250 to come up" - I had to manually kill the process that was waiting for the printer to recover.



2) create input filter /usr/local/lib/if-hplj_2100:

# sudoedit /usr/local/lib/if-hplj_2100

 #!/bin/sh
 #  ifhp - Print Ghostscript-simulated PostScript on a HP LaserJet 2100
 # -- revisions --
 # swapped "lj5gray" for "ljet4" for higher (1200 dpi) resolution option
 # swapped "ljet4" for "pxlmono" due to papersize problems
 # ---------------
 #
 # For plain-text files:
 printf "\033&k2G" || exit 2

The magicfilter sends "\033E\033&k2G\033(0N" as a prefix, and "\033E" as suffix - I have no idea what any of this means! :) I tried to use your prefix but still no output on the printer.

 # For PS files:
 IFS=""
 read -r first_line
 first_two_chars=`expr "$first_line" : '\(..\)'`

 if [ "$first_two_chars" = "%!" ]; then
      exec 3>&1 1>&2
      /usr/pkg/bin/gs -dSAFER -dNOPAUSE -dBATCH -dQUIET -q -sDEVICE=lj5gray \
          -sOutputFile=/dev/fd/3 -sLETTERSIZE=letter -_ && exit 0
 else
      # For PCL files:
      echo "$first_line" && cat && printf "\033&l0H" && exit 0
 fi

What do you use to handle .pdf files (first-four-chars = "%PDF") ?  :)

 exit 2

2.1) ..and set the proper permissions:

# sudo chmod 755 /usr/local/lib/if-hplj_2100


3) create spool file /var/spool/output/lpd/hplj-2100:

# sudo mkdir /var/spool/output/lpd/hplj-2100

Spool directory is already there.

4) enable lpd in /etc/rc.conf:

# sudoedit /etc/rc.conf
...
# enable Line Printer Daemon:
lpd=YES	  lpd_flags="-lrs"    # -s use secure domain only
                             # -r allow print filters
                             # -l enable logging

did that


5) start lpd daemon:
# sudo /etc/rc.d/lpd start

Did that, too.


--

I've also experimented with "raw" printing using ncat(1) plus gs(1) if
printing a PS/PDF file):

% cat cat_sitter.ps | /usr/local/lib/if\-hplj_2100 | ncat 192.168.1.12 9100

This works pretty well for occasional use.


Lastly, some HP printers have an FTP server running where you can basically
just upload a file and the file prints.  Mine does and will print plain text
and PCL files just fine that way.

Hope this helps,

It was a good try, but unfortunately it did not help. I'm still using the old laptop for printing.

Thanks for trying.



+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+


Home | Main Index | Thread Index | Old Index