Debug printing proplems

Hi, I have followed the Handbook's Chapter 11 Printing manual and have successfully set up my network printer. I have successfully printed plain text and PostScript files.

Now, however I cannot print anymore. I don't understand the situation. Can you help me find the cause of my proplem? Here is my setup:
Code:
# ls -dl /var/spool/lpd/lp
drwxrwx---  2 daemon daemon 13 Sep 23 08:52 /var/spool/lpd/lp

Code:
# /etc/printcap
# My printer's hostname is XC-6EF463, I have checked that
lp:\
    :lp=:rm=XC-6EF463:rp=raw:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/lp:\
    :if=/usr/local/libexec/lf2crlf:\
    :lf=/var/log/lpd-errs:

Code:
# cat /usr/local/libexec/lf2crlf
#!/bin/sh
CR=$'\r'
/usr/bin/sed -e "s/$/${CR}/g"

Code:
# grep lpd /etc/rc.conf
lpd_enable="YES"

Code:
# tail -n 5 /var/log/lpd-errs

Sep 20 02:50:31 bedna lpd[1197]: lpd startup: logging=0
Sep 20 03:03:56 bedna lpd[1173]: lpd startup: logging=0
Sep 20 03:28:43 bedna lpd[1190]: lpd startup: logging=0
Sep 20 03:50:19 bedna lpd[1185]: lpd startup: logging=0
Sep 23 09:15:00 bedna lpd[26755]: lpd startup: logging=0

Here is what I'm trying to print (but nothing gets printed):
Code:
# printf "1. This printer can print.\n2. This is the second line.\n" | lpr

There is a strange thing at the end of the lpq output
Code:
# lpq -a
lp:
bedna: Warning: no daemon present
Rank   Owner      Job  Files                                 Total Size
1st    root       47   (standard input)                      55 bytes

lpq: lp: Address family for hostname not supported

Code:
# lpc status all
lp:
    queuing is enabled
    printing is enabled
    1 entry in spool area
    printer idle

Code:
# ls -l /var/spool/lpd/lp
total 7
-rw-r--r--  1 root   daemon  4 Sep 23 09:15 .seq
-rw-rw----  1 daemon daemon 49 Sep 23 09:15 cfA047bedna
-rw-rw----  1 root   daemon 55 Sep 23 09:15 dfA047bedna
-rw-rw-r--  1 root   daemon  0 Sep 23 08:37 errs.7xFMN54
-rw-rw-r--  1 root   daemon  0 Sep 23 08:46 errs.8JCoTeo
-rw-rw-r--  1 root   daemon  0 Sep 23 09:15 errs.CO1lA4d
-rw-rw-r--  1 root   daemon  0 Jul  1 17:00 errs.DZnu8Nn
-rw-rw-r--  1 root   daemon  0 Sep 23 08:15 errs.IxmkZAG
-rw-rw-r--  1 root   daemon  0 Sep 23 08:20 errs.cxS9Ed4
-rw-rw-r--  1 root   daemon  0 Sep 23 08:17 errs.fzS9Reh
-rw-rw-r--  1 root   daemon  0 Jul  1 17:01 errs.g3c9gWR
-rw-rw-r--  1 root   daemon  0 Sep 23 08:20 errs.qHKvFPo
-rw-rw-r--  1 root   daemon  6 Sep 23 09:15 lock
-rw-rw-r--  1 root   daemon 21 Jul 29 08:25 status

Code:
# cat /var/spool/lpd/lp/.seq
048

Code:
# cat /var/spool/lpd/lp/lock
26766

Code:
# cat /var/spool/lpd/lp/status
sending to XC-6EF463

Can anyone see why my printer would not be printing? As far as I know my router is not blocking the printer. All I see is that the hostname is not resolved:

Code:
# ping XC-6EF463
ping: cannot resolve XC-6EF463: Address family for hostname not supported

But I am not sure if this hostname was ever resolvable before, back when I was able to print. I did not change my hosts file. I can ping the printer directly py its IP:

Code:
# ping 192.168.2.47
PING 192.168.2.47 (192.168.2.47): 56 data bytes
64 bytes from 192.168.2.47: icmp_seq=0 ttl=64 time=76.331 ms
64 bytes from 192.168.2.47: icmp_seq=1 ttl=64 time=89.220 ms
64 bytes from 192.168.2.47: icmp_seq=2 ttl=64 time=111.274 ms
^C
--- 192.168.2.47 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 76.331/92.275/111.274/14.428 ms
 
rm means the printer runs lpd
if you want to print to 9100/raw (hp-jet-direct) use lp=9100@ip.addr
your printers name does not resolve
add printers name/ip to /etc/hosts

if your printer is configured to a fixed/static ip addr just replace it's name with the ip in /etc/printcap
 
I'd add that you may be filtering the print job unnecessarily. In your printcap
Code:
:if=/usr/local/libexec/lf2crlf:\
Is only needed by printers that stairstep the code which historically were dot matrix printers. You mentioned that you had successfully printed a postscript file in the OP. A postscript capable printer would not be a printer that would stairstep.

Usually, when a job hangs up at the printer queue, it's a filter problem.

My printcap in OpenBSD where the spool directory is named /var/spool/output/:
Less:
lp|HL-5450DN:\
 :lp=9100@192.168.1.3:\
 :if=/usr/local/libexec/br_filter:\
 :sd=/var/spool/output/lpd:\
 :lf=/var/log/lpd-errs:\
 :mx#0:\
 :sh

duplex:\
 :lp=9100@192.168.1.3:\
 :if=/usr/local/libexec/br_filter_duplex:\
 :sd=/var/spool/output/duplex:\
 :lf=/var/log/lpd-errs:\
 :mx#0:\
 :sh

env10:\
 :lp=9100192.168.1.3:\
 :if=/usr/local/libexec/br_filter_env10:\
 :sd=/var/spool/output/env10:\
 :lf=/var/log/lpd-errs:\
 :mx#0:\
 :sh

br_filter:
Less:
#!/bin/sh

/usr/local/bin/foomatic-rip -q -P \
        Brother-HL-5450DN_BR-Script3-Postscript-Brother-en \
        -o PageSize=Letter
br_filter_duplex:
Code:
#!/bin/sh

/usr/local/bin/foomatic-rip -q -P \
        Brother-HL-5450DN_BR-Script3-Postscript-Brother-en \
        -o PageSize=letter -o Duplex=DuplexNoTumble

My Brother HL-5450DN is postscript capable but I use the filters, with foomatic-rip, to control single vs double sided printing and page size. env10 is for printing addresses on #10 envelopes. foomatic-rip essentially allows the passing of printer control codes like cups does. I could also change resolution, print density, etc.

Thread 50281

Before I upgraded my printer, my old printer used PCL5 and needed the print job filtered by the ljet4 filter in ghostscript. This thread shows how the printer control codes were pulled from a *.ppd file:

Thread 50607
 
My problem was in resolving the host, as covacat has pointed out. I have solved it on my router. Now I can print again, same way as before. Not sure how my printer's hostname was resolved before.

shepper: When I run
printf "1. This printer can print.\n2. This is the second line.\n" | nc 192.168.2.93 9100
then it prints this text stair-stepped. My printer is a Xerox WorkCentre 6515. It cannot print pdfs. Printing a .pdf with lpr does not produce the desired result. I must manually convert each pdf to ps with pdftops() and then I can lpr the postscript file. It's annoying.
 
My problem was in resolving the host, as covacat has pointed out. I have solved it on my router. Now I can print again, same way as before. Not sure how my printer's hostname was resolved before.

shepper: When I run
printf "1. This printer can print.\n2. This is the second line.\n" | nc 192.168.2.93 9100
then it prints this text stair-stepped. My printer is a Xerox WorkCentre 6515. It cannot print pdfs. Printing a .pdf with lpr does not produce the desired result. I must manually convert each pdf to ps with pdftops() and then I can lpr the postscript file. It's annoying.
Xerox 6515 should be able to print PDF directly (as well as save scan as PDF).
In your browser type your printer IP address, log in as a system administrator (user admin, password 1111 or device serial number) then System / PDL Settings / PDF.

Also, you are not supposed to pipe ( | ) to nc, but redirect ( < ) to it. Please see:
To not waste too much of paper/toner and if there is no single page PDF (or PS) around, easiest way to make one is something like:
Code:
man -t bsdcat > bsdcat.ps
ps2pdf bsdcat.ps
and then nc your.printer.ip.address 9100 < bsdcat.pdf
My HP prints PDF straight away, for PS I have to press OK button on the printer.

P.S. Edit (24.09.2025)
For some strange reason man -t bsdcat | lpr prints straight away, just like .pdf with nc, but with .ps sent to nc printer displays "job received" and waits for its OK button to be pressed.

If you want to use it with CUPS, you'll need xrx6515.ppd. Also, please take a look at print/foo2zjs pkg.

If you want to use scanner, install graphics/sane-backends and edit saned.conf and /usr/local/etc/saned/xerox_mfp_conf to add
tcp your.scanner.ip.address
Test with scanimage –L
For GUI apps, check graphics/kooka, graphics/simple-scan or graphics/xsane .
 
There are a couple of different ways to handle the text.
1. There are two tools that convert text to postscript file;
print/enscript which is used in a filter in the FreeBSD handbook.
print/a2ps is more of a swiss-army knife that will convert a number of input file type to postscript.
If you utilize the smart filter in the FreeBSD handbook, it detects *.ps files and passes them through. As is, it will not detect a pdf but you could add a second stanza to detect them and filter through pdf2ps or pdftops. OpenBSD uses a2ps in their guide. a2ps is supposed to detect file type but the legacy configuration still uses an ancient, only available on archives version of adobe acrobat to convert pdf's

2. You could setup a second lpr printer in
/etc/printcap for text files
Code:
# /etc/printcap
# My printer's hostname is XC-6EF463, I have checked that
lp:\
    :lp=9100@hostip:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/lp:\
    :lf=/var/log/lpd-errs:

# XC-6EF463 for *.txt files
txt:\
    :lp=9100@hostip:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/txt:\
    :if=/usr/local/libexec/lf2crlf:\
    :lf=/var/log/lpd-errs:

Then make a second /var/spool/lpd print que
#cp -r /var/spool/lpd/lp /var/spool/lpd/txt
Verify that files in the new txt directory have the same r/w, owner and group as lp and correct if necessary.

You can use the same /var/log/lpd-errs for both printer.

3. You could manually use enscript or a2ps to generate a *.ps file or import the *txt file into libreoffice and print from libreoffice.

Last comment, if you ensure that your printer always has the same IP address, static or MAC reservation, you can save yourself some headaches in the event your router doles out a different IP to the printer.
 
There are a couple of different ways to handle the text.
1. There are two tools that convert text to postscript file;
print/enscript which is used in a filter in the FreeBSD handbook.
print/a2ps is more of a swiss-army knife that will convert a number of input file type to postscript.
If you utilize the smart filter in the FreeBSD handbook, it detects *.ps files and passes them through. As is, it will not detect a pdf but you could add a second stanza to detect them and filter through pdf2ps or pdftops. OpenBSD uses a2ps in their guide. a2ps is supposed to detect file type but the legacy configuration still uses an ancient, only available on archives version of adobe acrobat to convert pdf's

2. You could setup a second lpr printer in
/etc/printcap for text files
Code:
# /etc/printcap
# My printer's hostname is XC-6EF463, I have checked that
lp:\
    :lp=9100@hostip:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/lp:\
    :lf=/var/log/lpd-errs:

# XC-6EF463 for *.txt files
txt:\
    :lp=9100@hostip:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/txt:\
    :if=/usr/local/libexec/lf2crlf:\
    :lf=/var/log/lpd-errs:

Then make a second /var/spool/lpd print que
#cp -r /var/spool/lpd/lp /var/spool/lpd/txt
Verify that files in the new txt directory have the same r/w, owner and group as lp and correct if necessary.

You can use the same /var/log/lpd-errs for both printer.

3. You could manually use enscript or a2ps to generate a *.ps file or import the *txt file into libreoffice and print from libreoffice.

Last comment, if you ensure that your printer always has the same IP address, static or MAC reservation, you can save yourself some headaches in the event your router doles out a different IP to the printer.
There is no need for separate txt filter/queue, 6515 can handle txt, ps and pdf just fine. Reason that UJuwMLAx had
prints this text stair-stepped
problem, is that he piped it to nc instead of redirecting to it, please see #6 and my quote there from another thread.

P.S. Edit: What I wrote here is questionable, please see #10
 
To be clear, I listed them as options and enscript can be substituted for the stair stepping code as it converts an inputted *.txt to *.ps. Upside of enscript is a better looking print job with a downside of more processing time - likely less than a minute on most hardware.
The Handbook Smart Filter looks elegant and would avoid a second queue. Setting up a second queue gives the user fine grain control:
Code:
#!/bin/sh
#
#  psif - Print PostScript or plain text on a PostScript printer
#
IFS="" read -r first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

case "$first_two_chars" in
%!)
    # %! : PostScript job, print it.
    echo "$first_line" && cat && exit 0
    exit 2
    ;;
*)
    # otherwise, format with enscript
    ( echo "$first_line"; cat ) | /usr/local/bin/enscript -o - && exit 0
    exit 2
    ;;
esac
File above modified to test for both Postscript and PDF and if PDF -> pdftops
If neither then enscript
Code:
#!/bin/sh
#
#  print_filter - Print PostScript, PDF or plain text on a PostScript printer
#
IFS="" read -r first_line
first_four_chars=`expr "$first_line" : '\(....\)'`

case "$first_four_chars" in
%!PS)
    echo "$first_line" && cat && exit 0
    exit 2
    ;;
%PDF)
    ( echo "$first_line"; cat ) | /usr/local/bin/pdftops - - && exit 0
    exit 2
    ;;
*)
    ( echo "$first_line"; cat ) | /usr/local/bin/enscript -o - && exit 0
    exit 2
Edits for Clarity and adding modified PSIF: The above file would be saved as /usr/local/libexec/psif and /etc/printcap lf:/= edited to reflect the new filter name.
 
To be clear, I listed them as options.
The Handbook Smart Filter looks elegant and would avoid a second queue. Setting up a second queue gives the user fine grain control:
Code:
#!/bin/sh
#
#  psif - Print PostScript or plain text on a PostScript printer
#
IFS="" read -r first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

case "$first_two_chars" in
%!)
    # %! : PostScript job, print it.
    echo "$first_line" && cat && exit 0
    exit 2
    ;;
*)
    # otherwise, format with enscript
    ( echo "$first_line"; cat ) | /usr/local/bin/enscript -o - && exit 0
    exit 2
    ;;
esac
To be honest, after some thinking and testing, you might be right about separate filter/queue, and maybe UJuwMLAx does need :if=/usr/local/libexec/lf2crlf:\ if lpr sometext.txt output is stair-stepped, and if 6515 is printing only first line of text with lpr sometext.txt, this simpler filter will work:
Code:
sudo vim /usr/local/libexec/crlf
i
#!/bin/sh
/usr/bin/sed 's/$/\r/'
ESC
:wq
sudo chmod 555 /usr/local/libexec/crlf
And then add to /etc/printcap :if=/usr/local/libexec/crlf:\ . Probably there is no need for both.

BUT, those filters (l2crlf and crlf) will prevent lpr from printing pdf, so solution is to have two printer entries in printcap, one lp|PRINTERNAME:lp=9100@... without if filters and another txt|PRINTERNAME:lp=9100@... with lf2crlf or crlf filter, as shepper suggested in #7

Then lpr wil print pdf and ps, and lpr –Ptxt will print txt. If second is cumbersome, make alias lptx or something similar.
 
Back
Top