LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-27-2009, 05:31 PM   #1
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Rep: Reputation: 15
lpr and /dev/usb/lp0 ---- simple question


I have a USB printer connected to my Ubuntu system and I can do:
cat filename.ext >/dev/usb/lp0 and I can print something.

However, when I try to use lpr filename.ext nothing happens, and the print job remains in the queue.

what can I do to direct all lpr print jobs to lp0


thanks in advance!
 
Old 10-27-2009, 07:07 PM   #2
wfh
Member
 
Registered: Sep 2009
Location: Northern California
Distribution: Ubuntu Debian CentOS RHEL Suse
Posts: 164

Rep: Reputation: 44
You'll find good information here:

Command-line Printing and Options.

..things like:

lp -d printer filename
 
Old 10-27-2009, 07:55 PM   #3
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks!
I looked at the help manual you mentioned, but I didn't see how to redirect or configure the path.

The manual specifies using a printer name, and I would like to use the path.

Can it be done?

so I would like to get lpr to redirect or reroute print jobs to
/dev/usb/lp0 similar to cat filename.ext >/dev/usb/lp0

OR - if anyone cal tell me where to look for options on ">" because when I print a text file, it doesn't print it very nicely, and I am not sure how to print images and other types of files (.bmp, .jpg, .tif, ...)
I need to be able to print text files as they appear and not reformatted.


Thanks
 
Old 10-28-2009, 08:23 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
You might need to explain your reasoning why you want to use redirect to print vs CUPS. Using the redirect basically sends raw characters to the printer and bypasses the printer's drivers. Typically prints accept raw ASCII text characters using their default fonts but it will not use any special formatting. In a nutshell the job of the print driver is to convert your text file for example into a special language that the printer understands so what you see on the screen is what you will see on paper. Now if your file was in the language the printer understands then what you are asking will work. Postscript and PCL are common printer languages. BTW using the print to file printer option will create a postscript file.
 
Old 10-28-2009, 10:19 AM   #5
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by michaelk View Post
You might need to explain your reasoning why you want to use redirect to print vs CUPS. Using the redirect basically sends raw characters to the printer and bypasses the printer's drivers. Typically prints accept raw ASCII text characters using their default fonts but it will not use any special formatting. In a nutshell the job of the print driver is to convert your text file for example into a special language that the printer understands so what you see on the screen is what you will see on paper. Now if your file was in the language the printer understands then what you are asking will work. Postscript and PCL are common printer languages. BTW using the print to file printer option will create a postscript file.
The problem I am seeing is as follows:
When I plug my USB printer, I can find it at /dev/usb/lp0
Then, I try to print to it by typing lpr filename.txt but it never reaches the printer. When I check the lpr queue, I just see it there waiting since it doesn't recognize any printer on my system. So I guess what I should have been asking is how can I configure the lpr to recognize that I have a printer at /dev/usb/lp0
 
Old 10-28-2009, 11:49 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
Then, I try to print to it by typing lpr filename.txt but it never reaches the printer. When I check the lpr queue, I just see it there waiting since it doesn't recognize any printer on my system. So I guess what I should have been asking is how can I configure the lpr to recognize that I have a printer at /dev/usb/lp0
Use cups. It has an easy web interface:
http://localhost:631
Add Printer .....
...
Print a test page.
If all is well, set it as your default printer.
 
Old 10-28-2009, 01:34 PM   #7
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by tredegar View Post
Use cups. It has an easy web interface:
http://localhost:631
Add Printer .....
...
Print a test page.
If all is well, set it as your default printer.
Can I do this through command line?
 
Old 10-28-2009, 01:45 PM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
Can I do this through command line?
No. Not from what I have offered.

But why would you want to do that? People keep moaning that linux is "difficult". So there are now easy to use tools to configure pretty much everything if you are a "pointy & clicky" type of person. Why don't you use it (at least as a start) ?

If you want to do it with the command line you need to go back to
wfh's post and useful link at #2.

Read it all.

Follow the links. The information is there:

You have to tell cups where your printer is, and what sort of printer it is, & set it as default.
 
Old 10-28-2009, 05:34 PM   #9
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
see if you have a /etc/printcap file, I believe it is the file that lpr uses for printer information, I know it does in dsl linux. if you google it there is info out there on how to configure printcap.
 
Old 10-28-2009, 08:14 PM   #10
wfh
Member
 
Registered: Sep 2009
Location: Northern California
Distribution: Ubuntu Debian CentOS RHEL Suse
Posts: 164

Rep: Reputation: 44
Essentially what everyone is saying is this...you need to set up your printer so that it uses Common Unix Printing System (CUPS). Make sure your cupsd is installed and started:
Code:
$ ps ax|grep cups

 6647 ?        Ss     0:01 /usr/sbin/cupsd
If cups is running, you will be able to see your USB printer when you do this:

System > Administration > Printing > New Printer

...if you are using Ubuntu Gnome. *THEN* you can print from the command line as I posted yesterday:

Code:
lp -d printer filename
Try this and post what you're seeing. We can guide you througn any rough spots.

Last edited by wfh; 10-28-2009 at 08:18 PM.
 
Old 10-29-2009, 09:42 AM   #11
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks everyone. I really appreciate your help and efforts.

Here is what I've done, and I will do things in response to replies.

Quote:
Originally Posted by colorpurple21859 View Post
see if you have a /etc/printcap file, I believe it is the file that lpr uses for printer information, I know it does in dsl linux. if you google it there is info out there on how to configure printcap.
I looked into my /etc/printcap file and this is the content:
Code:
# /etc/printcap: printer capability database. See printcap(5).
# You can use the filter entries df, tf, cf, gf etc. for
# your own filters. See /etc/filter.ps, /etc/filter.pcl and
# the printcap(5) manual page for further details.

lp|Generic dot-matrix printer entry:\
        :lp=/dev/lp0:\
        :sd=/var/spool/lpd/lp:\
        :af=/var/log/lp-acct:\
        :lf=/var/log/lp-errs:\
        :pl#66:\
        :pw#80:\
        :pc#150:\
        :mx#0:\
        :sh:

# rlp|Remote printer entry:\
#         :lp=:\
#         :rm=remotehost:\
#         :rp=remoteprinter:\
#         :sd=/var/spool/lpd/remote:\
#         :mx#0:\
#         :sh:
I noticed in the first entry that it is refering to lp0, but it is a dot-matrix printer...


Now, for the second reply, I know I don't have cups installed.

Quote:
Originally Posted by wfh View Post
Essentially what everyone is saying is this...you need to set up your printer so that it uses Common Unix Printing System (CUPS). Make sure your cupsd is installed and started:
Code:
$ ps ax|grep cups

 6647 ?        Ss     0:01 /usr/sbin/cupsd
If cups is running, you will be able to see your USB printer when you do this:

System > Administration > Printing > New Printer

...if you are using Ubuntu Gnome. *THEN* you can print from the command line as I posted yesterday:

Code:
lp -d printer filename
Try this and post what you're seeing. We can guide you througn any rough spots.


One thing I would like to add is the reason I am trying to do this through command line and not through CUPS is because I am trying to get any printer connected to be used, and the common factor I found between them is the fact that all the USB printers I connected to my system appear under lp0, so I want to keep this part general. Therefore, I don't want my installation to be for a particular printer only, and if I plug a different printer, I prefer not to "add a printer" through cups.
Eventually, what I would like to happen is I will be receiving instructions through a program that will request to print a certain file, and I would like to get a command line based program working with it.

One thing I will try out, however, is to install CUPS and see if that solves my problem... I will write my results as soon as I get them...
 
Old 10-29-2009, 01:02 PM   #12
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
One thing I would like to add is the reason I am trying to do this through command line and not through CUPS is because I am trying to get any printer connected to be used ..[SNIP] ..I don't want my installation to be for a particular printer only, and if I plug a different printer, I prefer not to "add a printer" through cups.
I don't think this is going to work.

Just because "any printer" is on lp0 doesn't mean that you can use it.

All printers are different. That's why they generally need "drivers" which tell the OS what the printer's capabilities are, and how it can be used.

If you just plugged any random USB printer into a windows computer, would you expect to be able to print to it without "installing drivers" or "Add New Printer"?

I don't think so. But I haven't configured win in years, maybe it works better now

cups is the way to go though.
 
Old 10-30-2009, 09:29 AM   #13
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
OK, I installed cups, and I retyped the command (below) and this is what I got:

Code:
root@ubuntu:/etc# ps ax|grep cups
 1709 ttyS0    S+     0:00 grep cups
When I type lp command, I get -bash: lp: command not found

I was trying to navigate to /etc/cups but the directory doesn't exist. What should I do?
 
Old 10-30-2009, 12:54 PM   #14
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
You need the cups server daemon to be installed and running.

On my system the package is called cupsys

Code:
tred@vaio:~$ ps -Al | grep cups
5 S     0  5419     1  0  80   0 -  1480 -      ?        00:00:00 cupsd
tred@vaio:~$
Then you can set it up with its web interface which can be found at http://localhost:631

But, did you read my post at #12 ? I don't think this is going to do what you want - "I am trying to get any printer connected to be used"
 
Old 10-30-2009, 01:49 PM   #15
v333k
Member
 
Registered: Apr 2004
Location: 127.0.0.1
Posts: 38

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by tredegar View Post
You need the cups server daemon to be installed and running.

On my system the package is called cupsys

Code:
tred@vaio:~$ ps -Al | grep cups
5 S     0  5419     1  0  80   0 -  1480 -      ?        00:00:00 cupsd
tred@vaio:~$
Then you can set it up with its web interface which can be found at http://localhost:631

But, did you read my post at #12 ? I don't think this is going to do what you want - "I am trying to get any printer connected to be used"
Yes - I realized that my choice of words wasn't the best.

I am aware of the driver requirement, but what I was trying to say is that I didn't have one USB printer that I wanted to work, I wanted to get the general idea of how to get any printer to work.

If you have more thoughts on how Ubuntu handles a newly plugged USB printer, what it does and if the driver is not found, how it handles it?

As for windows, I know that they have general printer drivers that come with the OS, so when you plug a new printer, it goes through a hardware installation process but almost never requests a manually entered driver or online search for a driver...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/dev/usb/lp0 disappears!! Hammett Linux - General 1 09-15-2007 09:23 AM
problems with /dev/usb/lp0 hazeposse Linux - Software 0 05-02-2006 04:58 AM
/dev/usb/lp0 doesn't exist Luc484 Linux - Hardware 2 01-22-2006 04:44 PM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 03:22 PM
Why is the /dev/usb/lp0 not recognized ... zikfreak Linux - General 6 11-25-2001 11:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration