Solved Unable to print from newly installed FreeBSD.

I have a new installation of FreeBSD:
Code:
uname -a
FreeBSD pr5.blank.blank 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

I've enabled printing in rc.conf:
Code:
# more /etc/rc.conf
saver="blank"
blanktime="30"
clear_tmp_enable="NO"
usbd_enable="YES"
lpd_enable="YES"
samba_server_enable="YES"
#ftpd_enable="YES"
zfs_enable="YES"
# disable sendmail to avoid issues with DNS and hostname
sendmail_enable="NONE"
keymap="uk"
hostname="pr5.blank.blank"
ifconfig_re0="inet 192.168.0.5 netmask 255.255.255.0"
defaultrouter="192.168.0.2"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
################## eof rc.conf #########################

I've created a spool directory
Code:
root@pr5:/var/spool # ls -lrt
total 29
drwx------  2 root   daemon    2 May 12 09:15 opielocks
drwxr-xr-x  2 root   daemon    2 May 12 09:15 mqueue
drwxr-xr-x  2 root   daemon    2 May 12 09:15 lpd
drwxrwx---  2 root   mail      2 May 12 09:15 dma
drwxr-xr-x  3 root   daemon    4 Sep 12 11:15 output
drwxrwxr-x  2 uucp   dialer    3 Nov  8 06:05 lock
drwxrwxrwx  2 root   wheel     2 Nov  8 13:05 lp
drwxrwxrwx  2 root   wheel     2 Nov  8 13:06 raw
drwxrwx---  2 smmsp  smmsp   830 Nov  8 13:46 clientmqueue
drwxrwxrwx  2 root   wheel     5 Nov  8 13:46 brother

I've created an interface file:
Code:
more /usr/local/libexec/broif
#! /bin/sh
#/usr/local/libexec/broif
# interface file for Brother HL-2150N
printf "\033&k2G" && cat && printf "\033&l0H" && exit 0
# NB elle nought capital aitch in the second prinf
exit 2
################ eof broif ############################

And I've edited /etc/printcap:
Code:
/etc/printcap:
lp|printer|default|Brother HL-2150N:lp=:rm=192.168.0.11:rp=brother:sd=/var/spool/brother:if=/usr/local/libexec/broif:
################### eof printcap #######################

If I try to send a text file to the printer (# lp /etc/rc.conf) I get no output and lpq shows no queued files. I have another FreeBSD system which, although older (FreeBSD 10.3) seems to be set up identically, is on the same ntework and prints successfully to the target printer. Really I'm at a loss as to how to diagnose this. What tools should I be using to try to understand what's going on. Advice please. Ta.
 
Code:
drwxrwxrwx 2 root wheel 2 Nov 8 13:05 lp
drwxrwxrwx  2 root   wheel     2 Nov  8 13:06 raw
...
drwxrwxrwx  2 root   wheel     5 Nov  8 13:46 brother
Please don't do silly things like this. Just running chmod 777 on something because you think there are permission issues is a REALLY BAD idea. Besides that, the directory is /var/spool/lpd/lp, not /var/spool/lp.

 
What I use for pdfs is to convert them to ps with pdf2ps, then run netcat. (my printer's IP is 192.168.1.50)
Code:
nc 192.168.1.50 9100 < file.ps
Depending upon what you have to print, this may be work as a stopgap till you figure it out.
 
Well, I can get print output now. I suspect the changes I made to the spool directory, and changing the rp parameter from brother to raw and adding the mx#0 parameter may have had no impact. Additionally, I've deleted the spool directories mentioned by SirDice. I think what made the difference was using the lpr command rather than lp.

However, I'd like to be able to print using lp as I've hard coded lp in many places, in an application I've made for myself. How may I enable printing using lp?
 
lp(1):
Code:
     The lp utility is a front-end to the print spooler as required by the
     IEEE Std 1003.2 (“POSIX.2”) specification.  It effectively invokes lpr(1)
     with the proper set of arguments.
 
Thanks for that SirDice. I can now print using lp. However, only when I add the -c parameter. So $ lp -c /etc/rc.conf works but not $ lp /etc/rc.conf. Nor $ lp -dlp /etc/rc.conf. Is there any way to make the parameter -c the default?

[Edit] I've added default and printer to the /etc/printcap file like this:

lp|default|printer:lp=:rm=192.168.0.11:rp=raw:sh:mx#0:sd=/var/spool/lpd/lp:lf=/var/log/lpd-errs:if=/usr/local/libexec/broif:
and, after a restart, tried $ lp -dprinter /etc/rc.conf and $ lp -ddefault /etc/rc.conf without success.
 
It looks like alias might do the job. I just tried $ alias lp="lp -c" then lp /etc/rc.conf and got a printout. Where is the appropriate place to set this alias as system wide?
 
Back
Top