News for hackers. Stuff that matters.
Re:Getting my daily news from a dot matrix printer by jolmg on Friday October 04, 2024 @04:33PM (#41745313)
> 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.

Re:Getting my daily news from a dot matrix printer by mrighele on Friday October 04, 2024 @05:28PM (#41745758)
> 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/

Re:Getting my daily news from a dot matrix printer by SoftTalker on Friday October 04, 2024 @10:28PM (#41747293)
OpenBSD does as well. The advantage is you don’t need CUPS.
Re:Getting my daily news from a dot matrix printer by jolmg on Sunday October 06, 2024 @01:43AM (#41755019)
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.