How to print both from the command line as well as through CUPS?

I have a printer that is being used for two purposes:

  • Printing of regular documents (Word, Internet pages, etc)
  • Direct printing from the command line (done by echo "text" > /dev/usb/lp0)

This all worked fine in a previous version of Ubuntu. However, recently we upgraded to 11.10 and encountered a problem. First of all, the printers are not added to /dev/usb anymore. So I can not echo to this path, and am unable to achieve printing from the command line.

After some hassle, I was able to find a workaround. This workaround was editing /etc/modprobe.d/blacklist-cup-usblp.conf. This file reads:

# cups talks to the raw USB devices, so we need to blacklist usblp to avoid
# grabbing them
blacklist usblp

After commenting this blacklisting, the device appears properly in /dev/usb, as lp0. I had a problem with the permissions of lp0, but this was solved by the answer from Luis Felipe Barrera Mora.

However, I now have one major issue to resolve. After I commenting the blacklisting, the printer stopped working when printing from Word documents. This is logical, because I disable something that CUPS needs. So basically I now only have the option to either enable regular CUPS printing and no command line printing, or I have command line printing and no CUPS printing.

UPDATE

For completeness: I in fact have two printers connected at the same time. One is used to print both using CUPS and the command line. The other one - an Epson receipt printer - is only used for command line printing. I've spent many days trying to get it running using CUPS but this was not possible. However, this means that the lpr command will not solve the problem, because I can not get this second printer to function under CUPS. I really need to be both able to access /etc/dev/lp0 (or a similar path) AND print using CUPS at the same time.


Solution 1:

I have the same problem, if you always add permissions to the file lp0, you must edit the printer rules:

$ gksudo gedit /lib/udev/rules.d/70-printers.rules

add [, MODE="0666"]

The file contains:

ACTION=="add", ... KERNELL="lp*" ... , MODE="0666"

Solution 2:

Why don't you use lpr to print form the command line? Like:

echo "text" > /tmp/someFileName
lpr -P YourPrinter /tmp/someFileName

It's a workaround, but should be an easy way to do what you want without changing some permissions...

Solution 3:

Open a web browser to http://localhost:631/ to configure CUPS. You should be able to print from the command line via echo "text" | lpr. Use lpstat -t to see all of CUPS' status information, lpstat -d to see the system's default printing destination, man lpstat for more, man lpr for specifying which printer.

All printing should go via CUPS - it manages queues, printers, ...