FreeBSD and JetDirect

I have a HP LaserJet 9000N hooked up to the network and configured.

nc 192.168.1.1 9100 < myfile.txt
works just fine from FreeBSD shell.

Now I would prefer to setup a FreeBSD print server.

I have read the howto's, but to be honest with apsfilter, magicfilter, cups, lpd, gutenbergprint, hplip, I believe I am getting things confused.

I have been able print using lpd() and /etc/printcap from different machines pointing back to my FreeBSD print server. But I haven't been able to print from different trays.

I prefer not to use CUPS, as I have just PostScript printers on the network (my understanding is that cups excels in the non-PostScript space).

So, what is the recommend method or if there are many recommended methods: what is your recommended method?

Thanks,

Bill
 
You already have a FreeBSD print server. If you want to use a different tray, that needs to be part of the PostScript file. There are threads here showing filters that add the information, but I apparently did not bookmark the one that showed using a filter to enable duplexing. Tray selection is very similar.
 
Excuse my ignorance here but that would mean I would need a filter to change the tray.

So my printcap file would look something like this:

Code:
billtesttray2:\
        :lp=:rm=192.168.1.119:rp=text:lf=/var/log/lpd-errs:\
        :of=/path/trayfilter:\
        :sd=/var/spool/lpd/billtesttray2:mx#0:sh:

Or am I completely off?

Thanks,

Bill
 
I installed apsfilter and test printing works just fine.

My problem is that is always prints from the same tray.

Code:
lpr -Pbillhog -C tray0 ~norton/testpage.txt
lpr -Pbillhog -C tray1 ~norton/testpage.txt
lpr -Pbillhog -C tray2 ~norton/testpage.txt

All print from tray 3.

I am not sure how to write a filter for this as I can't even get it to work from the command line?

What am I missing?

Thanks,

Bill
 
Not sure if I should ask here or start a new thread.

I read(post from 2000) that if you use
Code:
rp=raw:

then lpd() completely bypasses any filter.
I was getting stair-stepping so I changed to
Code:
rp=ascii:
and text prints fine now but I am worried about printing non-ASCII items.

Same post said that apsfilter doesn't work well with remote printers. Is this still true?

Ideas?

Bill
 
Last edited by a moderator:
Not sure if I should ask here or start a new thread.

I read(post from 2000) that if you use
Code:
rp=raw:

then lpd() completely bypasses any filter.

No, that's not accurate. The FreeBSD lpd() command does not do that. However, there is a queue named raw built into the JetDirect. Print data sent to that queue is printed without any changes.

I was getting stair-stepping so I changed to
Code:
rp=ascii:
and text prints fine now but I am worried about printing non-ASCII items.

The Handbook printing chapter shows how to use filters for that.

Same post said that apsfilter doesn't work well with remote printers. Is this still true?

No idea, I have never used print/apsfilter.
 
First, thanks to wblock@ for your help.

Second, I uninstalled print/apsfilter as I could never get it to work.

Third, I never could get printing working to other trays even when I directly edited the PostScript file. I am still looking into this.

Fourth, I used wblock@'s psif script but modified it for PDF files and TIFF files. Some changes had to be made (read kept stripping out the NULLs in the TIFF file).
There may be some unforeseen problem with the script, so use with discretion.
I thought others might find it useful.

Code:
#!/usr/local/bin/bash

IFS="" read -N 2 -r -d '' first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

case "$first_two_chars" in
%!|\033%%)
    # %! or ESC% : PostScript job, print it.
    echo -n "$first_line" && cat && printf "\004" && exit 0
    exit 2
    ;;

MM)
    # tif file
    # little nervous a doc could start with MM
    ( echo -n "$first_line"; cat ) \
    | /usr/local/bin/fax2ps -W8.5 -H10.5 && printf "\004" && exit 0
    exit 2
    ;;

%P)
    # %P not sure if other files other than PDF start with %P
    ( echo -n "$first_line"; cat ) \
    | /usr/local/bin/pdf2ps - - && printf "\004" && exit 0
    exit 2
    ;;

*)
    # otherwise, format with enscript
    ( echo -n "$first_line"; cat ) \
      | /usr/local/bin/enscript -o - && printf "\004" && exit 0
    exit 2
    ;;
esac
 
file(1) is a better way to detect file type. The original psif got away without it because PostScript files follow a well-known format, and it kept the demonstration relatively simple.
 
file(1) is a better way to detect file type. The original psif got away without it because PostScript files follow a well-known format, and it kept the demonstration relatively simple.

I was wondering this and starting writing a script to use file instead of the above. Having a couple of problems but I am no sh guru.

Bill
 
I have a HP LaserJet 9000N hooked up to the network and configured.

nc 192.168.1.1 9100 < myfile.txt
works just fine from FreeBSD shell.

Now I would prefer to setup a FreeBSD print server.

I have read the howto's, but to be honest with apsfilter, magicfilter, cups, lpd, gutenbergprint, hplip, I believe I am getting things confused.

I have been able print using lpd() and /etc/printcap from different machines pointing back to my FreeBSD print server. But I haven't been able to print from different trays.

I prefer not to use CUPS, as I have just PostScript printers on the network (my understanding is that cups excels in the non-PostScript space).

So, what is the recommend method or if there are many recommended methods: what is your recommended method?

Thanks,

Bill

Unfortunately you are beating a dead horse. I used until 1.5 year ago this simple printcap file on my OpenBSD machine

Code:
lp|HP|HP-Photosmart_5200:\
        :lp=/dev/ulpt0:\
        :af=/etc/foomatic/HP-PhotoSmart_C5200.ppd:\
        :if=/usr/local/bin/foomatic-rip:\
        :sh:sd=/var/spool/output:\
        :lf=/var/log/lpd-errs:

Then the idiots from the Linux foundation got the idea that foomatic-rip should no longer support LPD or any other spooling except CUPS for that matter because as we know everyone has to use CUPS. Long story short my printer still works but I have to call foomatic-rip manually to convert a file from PostScript into PCL5 and then to stream it to lpd. Obviously foomatic-rip is just a Perl wrapper which calls the driver for me. Somebody suggested you Apsfilter. Please don't use that ancient piece of software which is just a cheap wrap around foomatic-rip. Just spend $50 for a used printer which supports PostScript and remove any input filters from your printcap file. Another idea is that you just a write small input filter yourself (I have done that for LaserJet 4) as it likely uses GhostScript drivers and it is essentially two liner. Just suppress the printer wake up and a second line is to call the GhostScript command with a bunch of options.
 
I have dumped print/apsfilter, I simply couldn't get it to work. Too bad about foomatic-rip, what was the reason for doing this?

I have a PostScript printer, but I need to be able to print PDF, DVI, TIFF files from the command line.

It currently works but I believe it could be a little cleaner than what I did above.

Bill
 
I have a postscript printer, but I need to be able to print pdf, dvi, tiff files from the command line.
So what prevents you from doing it. Conversion filter is just a Perl script which detect the type of the file and call conversion program. So when you send for example PDF file to printer foomatic-rip detect it is PDF file. It calls pdf2ps utility and once the file is translated into PostScript calls the driver which converts PostScript to the language understandable by printer like PCL6 for example. Check out a2ps application. It essentially converts everything to PostScript and sends to default printer. So if you have a PostScript printer: a2ps -1 myfile.pdf will print the file on your printer.
 
With regards to PDF's, my current filter does this. But I think it could be a[]lot better.

I had never heard of a2ps until your post. It doesn't seem to work with TIFF files though. It prints out garbage saying it can't find tiff.ssh.

It prints out DVI and PDF files just fine though.

Bill
 
graphics/ImageMagick or graphics/GraphicsMagick can convert between almost any formats, including PostScript.

With regards to TIFF files, fax2ps works just fine. print/a2ps works just fine except for TIFF files.

So I figure out what's wrong with a2ps or write a filter to call a2ps for everything except TIFF files. Or maybe just improve my current script.

I need users to be able to do
lpr foo.dvi
lpr foo.tiff
lpr foo.pdf
without intervention from me, preferably using only one queue.

Bill
 
I know that many people were very frustrated when upstream broke foomatic-rip for LPD users. Thanks to Antoine Jacoutot of OpenBSD many of us will be CUPS free for years to come. I am leaving internet trace for people who would be looking for the info but Antoine documentation which comes with OpenBSD

/usr/local/share/doc/pkg-readmes/cups-filters*

is golden standard.

In the nut shell what I did:

0. Install foomatic-rip, drivers (in my case hpijs), a2ps, ImageMagick

1. Edit /etc/printcap as
Code:
lp|HP|HP-PhotoSmart_C5200:\
  :lp=/dev/ulpt0:\
  :if=/etc/foomatic-rip/script.sh:\
  :sh:sd=/var/spool/output:\
  :lf=/var/log/lpd-errs:

2. Create /etc/foomatic-rip.script.sh and make it executable

Code:
#!/bin/sh

/usr/local/bin/a2ps -BRq --columns=1 -o - | \
  /usr/local/bin/foomatic-rip -P HP-PhotoSmart_C5200 --ppd \
  /etc/foomatic-rip/direct/hp-photosmart_c5200_series-hpijs.ppd

3. Add hp-photosmart_c5200_series-hpijs.ppd to /etc/foomatic-rip/direct. You can either find it in the database or use foomatic-ppdfile to create it.

4. Adjust permission on ulpt0 and ugen devices.

5. Start lpd daemon and be happy camper.
 
Back
Top