English
Ask Your Question
2

Redirect program output to my usb printer

asked 2012-02-14 16:05:22 +0000

Dieter gravatar image

Hello

I'm using Fedora 16 with a Brother DCP-150C printer connected via USB. Ich have absolutely no problems printing any document or text file via LibreOffice or Gedit. But, as soon as I try to redirect program output from any C program to my connected printer as follows

./myprog > /dev/usb/lp0

then nothing happens. Instead I get a 'bash: /dev/usb/lp0: Permission denied' message. Note that /dev/usb/lp0 is the device my printer is connected to.

Can anybody tell me please what I'm doing wrong or what do I should do that program redirection works on my machine.

Thank you in advance for your help.

edit retag flag offensive close delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-02-14 20:27:32 +0000

ztank1013 gravatar image

Here you will find interesting command line printing techniques and options:

http://www.cups.org/documentation.php/options.html

edit flag offensive delete publish link more

Comments

This article was very helpful and solved my problem. Thank you!

Dieter ( 2012-02-15 09:42:01 +0000 )edit
0

answered 2012-02-14 19:32:25 +0000

You have to use the lp command to send to the printer device. Using a pipe is easiest.

That is:

$ ./myprog | lp
edit flag offensive delete publish link more

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

Add answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers to your questions.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Stats

Asked: 2012-02-14 16:05:22 +0000

Seen: 547 times

Last updated: Feb 14 '12