network printer installation

Hello I have a HP Laserjet 2420 printer with a network card connected and configured for LPR. Is there a tool or tutorial on how to configure freebsd 11 to do LPR printing?
thanks
nedry
 
This is my /etc/printcap. Make sure you read firstly printcap(5) before you try to understand what I wrote

Code:
# Remote printer must use jetdirect since foomatic-rip doesn't speak LPD
rp|HL-5250DN:\
        :lp=9100@192.168.3.15:\
        :if=/etc/foomatic-rip/script_brother.sh:\
        :sh:sd=/var/spool/output/brother:\
        :lf=/var/log/lpd-errs:

Note that script_brother.sh which I have to use because print/foomatic-filters no longer support LPD spooling. The insist on using CUPS and their filters are the part of CUPS now.
This is my /etc/foomatic-rip/script_brother.sh
Code:
#!/bin/sh

/usr/local/bin/a2ps -BRq --columns=1 -o - | \
        /usr/local/bin/foomatic-rip -P HL-5250DN --ppd /etc/foomatic-rip/direct/brother-hl-5250dn-postscript-brother.ppd

Note that my printer is PostScript printer. The only reason I use PPD files is to avoid manually converting everything to PostScript before sending to printer and adjusting page size, font automatically.
 
Hi I have tried the following in /etc/printcap:
Code:
# Sample remote printer.  The physical printer is on machine "lphost".
# You can perform any kind of local filtering directly.  If you need
# local filters (e.g. LF -> CR-LF conversion for HP printers), create
# a filter script that sends the proper escape sequence to the printer
# and then concatenates stdin to stdout.
#
#
#remote|sample remote printer:\
lp:\
:lp=:rm=printer2:rp=raw:\
:sh:\
:mx#0:\
:sd=/var/spool/lpd/lp:\
:lf=/var/log/lpd-errs:
#
However I get the following error message when i run service lpd start
Code:
root@test-bsd:/usr/home/nedry # service lpd start
Starting lpd.
chkprintcap: Warning: new entry starts after line with trailing '\', at line 46 (entry lp)
chkprintcap: Warning: new entry starts after line with trailing '\', at line 47 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 48 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 49 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 50 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 51 (entry )
chkprintcap:    6 warnings from skimming /etc/printcap
chkprintcap: WARNING: found 6 entries when skimming /etc/printcap,
chkprintcap: WARNING:  but only found 0 queues to process!
root@test-bsd:/usr/home/nedry #
I have checked everything and I have read chap 9.1 basic printing in the FreeBSD Handbook.
thanks
Nedry
 
You have a syntax error in your printcap file.


Code:
lp:\
:lp=:rm=printer2:rp=raw:\

All that is very wrong!
 
ok well I must have miss interpreted the handbook because this is what it says:

As root, create /etc/printcap with these contents:

lp:\
:lp=/dev/unlpt0:\

This line is for a printer connected to a USB port.

For a printer connected to a parallel or “printer” port, use:

:lp=/dev/lpt0:\
For a printer connected directly to a network, use:

:lp=:rm=network-printer-name:rp=raw:\
Replace network-printer-name with the DNS host name of the network printer.
 
Most users find the JetDirect port (9100) to be the most reliable. JetDirect was developed by HP and your HP printer certainly supports the port. Use of the port is described in the next section of the handbook:

Code:
Network
For a printer supporting the LPD protocol:

:lp=:rm=network-printer-name:rp=raw:\
For printers supporting port 9100 printing:

:lp=9100@network-printer-name:\
For both types, replace network-printer-name with the DNS host name of the network printer.

In FreeBSD it is also recommended that you have the printer name entered in /etc/hosts. If your entry is correct, you should be able to ping(8) the printer.
 
:lp=:rm=network-printer-name:rp=raw:\
Replace network-printer-name with the DNS host name of the network printer.
But that is not what you file is saying. Your file is saying when I remove \ from lp:\ the following

Code:
lp::lp=:rm=printer2:rp=raw:\
That is so obviously wrong. Assuming that your printer FQDN is indeed printer2 (which I don't believe for a second if you are on the home network) The code should read
Code:
lp=:rm=printer2:rp=raw:\

So remove

Code:
lp:\
:
 
Hrrm, both the handbook and wblock@'s page show
Code:
lp:\
:lp=<whatever>
Actually, just checked and yup, it works for me with what the handbook and wonkity.com say, even though, as you point out, it should actually result in lp::lp and so on.
<shrug>.
My /etc/printcap (at the end, after all the commented stuff)
Code:
lp:\
       :lp=:\
        :sh:\
        :mx#0:\
        :rm=192.168.1.50:\
        :rp=raw:\
        :sd=/var/spool/lpd/lp:\
        :lf=/var/log/lpd-errs:

So, I guess it does usually work, I've always blithely followed wonkity.com's page on it, http://www.wonkity.com/~wblock/docs/html/lpdprinting.html.
Though, as you (Oko) point out, that comes out to lp::lp= and I would think that wouldn't work.

To nedry, in case you're not familiar with the syntax (though you probably are), a \ at the end of a line means to continue it on the next line so
Code:
something\
something else
is read as something something else, as if it were one line. That's fairly well known and why Oko thought it obvious. (But he's smarter than me, and it wasn't obvious to me till he explained it.)
 
Actually, just checked and yup, it works for me with what the handbook and wonkity.com say, even though, as you point out, it should actually result in lp::lp and so on.
The /etc/printcap file uses tercmap(5) format. As such, each entry describing a printer starts with a name, or set of names for the printer being described by the corresponding set of attributes.

From termcap(5):
Entries in termcap consist of a number of `:'-separated fields. The first entry for each terminal gives the names that are known for the terminal, separated by `|' characters. The first name given is the most common abbreviation for the terminal. The last name given should be a long name fully identifying the terminal, and all others are understood as synonyms for the terminal name. All names but the last should be in lower case and contain no blanks; the last name may well contain upper case characters and blanks for readability.
I guess the thing that can be a little confusing here is that 'lp' happens to be the name of an attribute, as well as the name of the default printer being used if no PRINTER environment variable is set, as stated in printcap(5):
The default printer is normally lp, though the environment variable PRINTER may be used to override this. Each spooling utility supports an option, -P printer, to allow explicit naming of a destination printer.
If I remember it correctly, the JetDirect module supports a number of different functions when used in lpd mode, depending on the remote printer (rp) attribute. With rp=auto the JetDirect module should be able to auto detect postscript and possibly also different end-of-line conventions (NL/CR/CRLF). Here's what I've used with a Postscript capable LaserJet 4+ printer:
Code:
lj4p_raw|HP Laserjet 4 Plus, Raw Mode:\
        :sh:lp=:\
        :rm=druecker:rp=raw:\
        :sd=/var/spool/output/lj4p_raw:\
        :lf=/var/log/lpd-errs:

lj4p_text|lp|HP Laserjet 4 Plus, Text Mode:\
        :sh:lp=:\
        :rm=druecker:rp=text:\
        :sd=/var/spool/output/lj4p_text:\
        :lf=/var/log/lpd-errs:

lj4p_auto|HP Laserjet 4 Plus, Auto Mode:\
        :sh:lp=:\
        :rm=druecker:rp=auto:\
        :sd=/var/spool/output/lj4p_auto:\
        :lf=/var/log/lpd-errs:

lj4p_binps|HP Laserjet 4 Plus, Binary Postscript Mode:\
        :sh:lp=:\
        :rm=druecker:rp=binps:\
        :sd=/var/spool/output/lj4p_binps:\
        :lf=/var/log/lpd-errs:
 
The example mickey shows takes advantage of the different queues available on a JetDirect device. Which queue names are supported could vary depending on the model, but I'd suggest using raw and doing all the processing on the computer. That avoids possible surprises with what the JetDirect might do. I do not recall the binps stuff at all and suspect that the JetDirect just treats that as a raw queue because because it is not one of the special queue names.
 
Which queue names are supported could vary depending on the model, but I'd suggest using raw and doing all the processing on the computer. That avoids possible surprises with what the JetDirect might do. I do not recall the binps stuff at all and suspect that the JetDirect just treats that as a raw queue because because it is not one of the special queue names.
The documention for my HP JetDirect 400n does not list the 'binps' (binary PostScript) queue, but the documentation of a HP JetDirect 680n does, so there are indeed slight differences with different JetDirect models. The support DVD even seems to include a Solaris utility that could be used to modify the queues on the JetDirect module.

As for the print queues, here's what the documentation of my JetDirect 400n says:
Code:
Step 2. Setting Up Print Queues
You must set up a print queue for each printer or printer personality
(PCL or PostScript) you use on your system. Also, different queues
are required for formatted and unformatted files. The queue names
text and raw in the following examples (see rp tag) have special
meanings.

Table 4.2 Supported Queue Names
raw, raw1, raw2, raw3 no processing
text, text1, text2, text3 carriage return added
auto, auto1, auto2, auto3 automatic

The line printer daemon on the HP JetDirect print server treats
data in the text queue as unformatted text or ASCII, and adds a
carriage return to each line before sending it to the printer. (Note
that the actual observed behavior is that a PCL line termination
command (value of 2) is issued at the beginning of the job.) The line
printer daemon treats data in the raw queue as formatted files in
PCL, PostScript, or HP-GL/2 languages and sends the data without
change to the printer. Data in the auto queue will be automatically
processed as text or raw, as appropriate. If the queue name is not
one of the above, the HP JetDirect print server assumes it to be
raw1.

LPD on UNIX Systems

Configuring Print Queues for BSD-based Systems
Edit the /etc/printcap file to include the following entries:

printer_name|short_printer_name:\
:lp=:\
:rm=node_name:\
:rp=remote_printer_name_argument:\ (this should be
text, raw, or auto)
:lf=/usr/spool/lpd/error_log_filename:\
:sd=/usr/spool/lpd/printer_name:

where printer_name identifies the printer to the user,
node_name identifies the printer on the network, and
remote_printer_name_argument is the print queue
designation.
 
  • Thanks
Reactions: Oko
Hello I have a HP Laserjet 2420 printer with a network card connected and configured for LPR. Is there a tool or tutorial on how to configure freebsd 11 to do LPR printing?
thanks
nedry

OMG how times change...for the better!!!! There is a nifty tutorial Getting Started with CUPS on FreeBSD 11.

Basic Steps:

Bash:
pkg install cups
#enable cups in rc.conf via vi or append
sudo echo "cupsd_enable=yes" >> /etc/rc.conf
#Start cups daemon
sudo service cupsd start
#Enable Remote Admin ***Note you will probably want to
# disable remote configuration after configuration is complete.***
cupsctl --remote-admin
#Now you should be able to install and configure the printer via web interface.
http://127.0.0.1:631

Just click on "Add Printer" or "Find New Printers" in the web configuration dialog under "Administration" menu. I had previously been trying to configure using the FreeBSD Manual pages and I'm sure those procedures work as well but for a quick setup the CUPS web interface is pretty nifty.

Hope this helps someone else!

-0xdxdt
 
Back
Top