Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> One of the things that this person does is simply echo to /dev/lp0.

> So, if I plug a USB printer into a computer, and ls > /dev/usbXXX, will it print today? Does that still "just work"?

Both of the following worked for me:

  printf 'hello\f' > /dev/usb/lp0
  printf 'hello\f' | nc -N $printer_ip 9100
This is on a Brother laser printer. Its programming guide is linked next to its manual online. The language is PCL, but you don't really need to know much about it to get simple stuff printed.

Neither of the above involve CUPS. Using the `lp`/`lpr` executable like in other comments requires the printer to be registered with CUPS first.

For `ls >`, the printer expects DOS line endings. `\n` just moves to a new line without "returning the carriage", so you need to pipe through `sed 's/$/\r/'` or use `nc -C`.

With the USB connection, you can print multiple times to build a single page and it won't come out until you provide the form feed. With the TCP connection, the page will be printed when the connection is closed.



> Using the `lp`/`lpr` executable like in other comments requires the printer to be registered with CUPS first.

In modern Linux distros, lp/lpd are usually shims provided for backward compatibility, but it doesn't have to be that way. For example FreeBSD seems to provide support for lpd without for cups [1], although I don't see any real advantage in doing that.

[1] https://docs.freebsd.org/en/books/handbook/printing/


OpenBSD does as well. The advantage is you don’t need CUPS.


But you do still need to register the printer prior to using, or at least have a basic registration set up that works with it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: