Page 1 of 2

[Solved]How to make a photocopy using a USB scanner and a network printer

Posted: Mon May 04, 2020 12:00 pm
by christophe60_fr
Hi,
GhostBSD-2020-04-30-XFCE, USB Epson Perfection 1650 scanner and HP Laserjet 200 Color m251nw network printer.

I asked this question a few years ago but I never got an answer and the problem is still there : xsane is installed as well as hplip.
The 2 packages work very well independently of each other. So I can print and scan without worry. Unless I want to scan a document and send it directly to the printer, in other words, if I want to make a photocopy.
In this case, I use the "copy" function of xsane, but after clicking on "Numériser" ("Scan"), I still get the same 4 error messages :
1) "Erreur pendant la sauvegarde Broken pipe" ("Error during backup Broken pipe"),
2) "Erreur pendant la sauvegarde Resource temporarily unavailable" ("Error during backup Resource temporarily unavailable"),
3) "Erreur pendant la sauvegarde Resource temporarily unavailable" ("Error during backup Resource temporarily unavailable"),
4) "Echec de l'exécution de la commande d'impression "lpr"" ("Failed to execution of the print command "lpr"".
It is true that examples of this type are not lacking on forums of all kinds, but I have so far found no solution.
Manually replace the lpr command in xsane configuration with lpr -P or lp whether or not followed by the name of the printer, uncheck create zlib ..., etc..., does not change anything.
My printer is in the file /hplip/data/models/. It is well recognized as the default printer.
So, where can the problem come from ?
Thank you for a solution.

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sat Jun 13, 2020 4:59 pm
by pcu71
I do not own a separate scanner, so I could not test this solution to the end, but I think this should solve your problem.
(For further information it is recommended to also read chapter 9 of the FreeBSD handbook.)

Explanation:
===============
Xsane uses lpr (and lp) for the printer.
When starting a terminal (i.e. xfce terminal or xterm or similar), and starting "xsane" from there, and then using the "copy" function of xsane, the user gets an error
"lpr :lp :unknown printer !"
This output shows that xsane wants to use the printer configured for the Line Printer (lpr), which is not started nor configured. So this has to be changed by doing the following steps:


Solution:
===============
As user "root" do the following:

1.)
# mkdir -p /var/spool/lpd/lp
# chown daemon:daemon /var/spool/lpd/lp
# chmod 770 /var/spool/lpd/lp

2.)
Edit file "/etc/printcap" and at the end append the following lines:
lp:\
:lp=:rm=<ip-address-of-your-printer>:rp=raw:\
:sh:\
:mx#0:\
:sd=/var/spool/lpd/lp:\
:lf=/var/log/lpd-errs:


If your printer is attached by USB, you should replce the line ":lp=rm=...." with this:
:lp=/dev/unlpt0:\
or, if you encounter problems, this:
:lp=/dev/:ulpt0\

3.)
After saving this file, the user should check the configuration with command "chkprintcap". If everithing is correct, the shell shows no output.


4.)
4.1)
Activate the service lpd by editing "/etc/rc.conf" and adding the following line:
lpd_enable="YES"

4.2)
# service lpd start


5.)
Test the lpr functionality by sending some text to the printer:
>echo "Hello Printer" | lpr

If the printer prints the text "Hello Printer", then lpr is now aware of it and the "copy" function of xsane should work.

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sat Jun 13, 2020 9:37 pm
by mapsware
That means Xsane invokes lpr without specifying a destination printer (-P PrinterName), expecting lpr to use the user's configuration

lpr selects the destination printer in the following order:
  1. If the -P PrinterName option was specified
  2. If PRINTER environment variable exist, it's value is used as the destination printer
  3. As a last resort, it use "lp" as the destination printer
More info in the manual of lpr

I think christophe60_fr it's using HPLIP as his printing system

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sun Jun 14, 2020 11:28 am
by christophe60_fr
@pcu71 (Pino ?),

Wow, fantastic job.

Here are my findings after following your tutorial :

After following steps 1 & 2, here is what gives the result of step 3 "chkprintcap" :
chkprintcap: Warning: new entry starts after line with trailing '\', at line 57 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 58 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 59 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 60 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 61 (entry )
chkprintcap: 5 warnings from skimming /etc/printcap
chkprintcap: WARNING: found 6 entries when skimming /etc/printcap,
chkprintcap: WARNING: but only found 1 queues to process!

Same result if I replace <ip-address-of-my-printer> with <name-of-my-printer>, or if xsane is modified at the level of the lpr command or not.

Step 4.2 "service lpd start" :
* Starting lpd ...
chkprintcap: Warning: new entry starts after line with trailing '\', at line 57 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 58 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 59 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 60 (entry )
chkprintcap: Warning: new entry starts after line with trailing '\', at line 61 (entry )
chkprintcap: 5 warnings from skimming /etc/printcap
chkprintcap: WARNING: found 6 entries when skimming /etc/printcap,
chkprintcap: WARNING: but only found 1 queues to process!

Step 5 ">echo Hello Printer" | lpr :
Redirection de sortie ambigue.
So the text is not printed.

BUT the good news is that a scanned document with xsane, using the "copy" function, is printed correctly. The "Broken pipe" error message pops up no more.

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sun Jun 14, 2020 1:54 pm
by pcu71
Glad to hear that "copy" function is now working correctly.
Regarding the error messages when running "chkprintcap": Please check whether you do not have typed a "\" where it is not needed.
Regarding Step 5, just write:
echo "Hello Printer" | lpr
Then it should work.

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sun Jun 14, 2020 2:52 pm
by christophe60_fr
Disappointment.
chkprintcap
chkprintcap: WARNING: found 6 entries when skimming /etc/printcap,
chkprintcap: WARNING: but only found 1 queues to process!

I had to remove each 5 "\", so no more warning with that.

A first echo "Hello Printer" | lpr
lpr: Unable to connect to /var/run/printer: No such file or directory
lpr: Check to see if the master 'lpd' process is running.
jobs queued, but cannot start daemon.

A second echo "Hello Printer" | lpr
No more message

No "Broken pipe" error message either when using the "copy" function, but no printing...

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Sun Jun 14, 2020 5:48 pm
by mapsware
If you are using GhostBSD with it's standard config, then GhostBSD it's using CUPS, you should not enable LPD/LPR.

Be careful, because a collision with lpr

LPD/LPR ==> /usr/bin/lpr

CUPS ==> /usr/local/bin/lpr

Try setting the environment variable PRINTER; to list the printers available in CUPS, use lpstat -p -d or set the default printer with lpoptions -d printer (CUPS Manual)

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Mon Jun 15, 2020 11:45 am
by christophe60_fr
I finally put everything back as it was at the beginning, considering that the "\" were only warnings.
One thing I notice is that adding the line "lpd_enable="YES"" to the file "/etc/rc.conf" does not work because the lpd service is not activated at boot. I see this by doing a # service lpd start.
Then using the "copy" function of xsane works correctly.

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Mon Jun 15, 2020 8:30 pm
by mapsware
As I said, you are using CUPS, because is what GhostBSD configure by default

Re: How to make a photocopy using a USB scanner and a network printer

Posted: Tue Jun 16, 2020 2:03 pm
by christophe60_fr
Hi mapsware,

Thanks for the links but I admit that I don't know how to use these informations.
Concretely, what am I supposed to do ?

# lpstat -p -d
printer HP_LaserJet_200_color_M251nw is idle. enabled since lun. 15 juin 20:54:22 2020
system default destination: HP_LaserJet_200_color_M251nw

What do you mean by "you should not enable LPD/LPR" ? I am now completely lost, especially since I had to reinstall GhostBSD which crashed without a warning and then I had to reactivate cupsd ...