Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending raw data through usb on linux

I'm printing some labels on a Zebra TLP-2844 printer, and have been doing it fine on Windows by sending the EPL instructions to the shared USB printer as follows:

type Label.prn > \my-pc\zebra

and it seems to work with serial ports too, with

type Label.prn > COM1

Now I'm trying to to the same on Linux, but it's getting really hard! My first guess was:

cat Label.prn | /dev/bus/usb/005/002

since my printer is on bus 005, device 002 (checked it with lsusb command) but it doesn't work at all, as I get the following:

bash: /dev/bus/usb/005/002: Permission denied

Any guesses?

like image 691
Lucas d. Prim Avatar asked Aug 19 '10 21:08

Lucas d. Prim


2 Answers

The command you did

cat Label.prn | /dev/bus/usb/005/002

will try to run /dev/bus/usb/005/002, which is not executable, hence "permission denied". The correct command would be, similar to windows

cat Label.prn > /dev/bus/usb/005/002

However, not sure if you actually can write anything to a printer like that in linux. If the printer is set up properly, you might also try:

lpr Label.prn
like image 148
unbeli Avatar answered Oct 05 '22 06:10

unbeli


In case anyone else is trying to access raw USB printer ports; The "permission denied" problem is circumvented by adding your user to group "lp", like so:

$ sudo usermod -aG lp USERNAME

where USERNAME is your username.

like image 40
Mike Avatar answered Oct 05 '22 05:10

Mike