NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Use network printer from NetBSD



On 2020-06-26 13:05, Rocky Hotas wrote:
On giu 26 10:38, JingYuan Chen wrote:
How about using pdf2ps and netcat ?

pdf2ps urpdf.pdf - | netcat -w 1 printer_IP printer_port

Thanks for this suggestion. I tried, but when using 515 as printer_port
nothing happens. When instead using 9100, in the printer display
`Receiving data' appears, but again nothing more happens.

The same if I use just a plain text string, terminated with `\004' as
suggested by Bob.

printf 'somestring\x04' | nc -w 1 printer_IP printer_port

A couple of simple, obvious comments.

It is totally meaningless to try and use netcat and send something to port 515. Port 515 is the lpd port. It actually have a protocol with a bunch of metadata and stuff required for any printing to happen. You will most likely never manually hack together something that just have a file that match everything expected to come when you talk to that port. Either setup the lpd system to talk to it, and then you use lpr to submit your print jobs, or don't bother with port 515. (And as mentioned, if you use lpd, then you might need to find out what the queue name on the printer is called as well, which is a different problem, but I would try using an empty queue name, unless I can find something in the official documentation from the printer manufacturer.)

Port 9100 is usually just a raw printer interface. Whatever you put in there is then going directly to the printer. This is something netcat can do for you just fine. However, if you send postscript, then the printer better understand postscript, or you'll not like the result... :-) If the printer understands PCL, then it will be perfectly happy being fed plain ASCII text, and it will print it. If the printer use some other protocol, then whatever you feed it on port 9100 might need to be massaged in some different way. This obviously depends on the printer manufacturer and specifics of that model. One thing is that if you send plain ascii, and it's a short text, you might want to send a formfeed after, or else the last page is in the buffer, but it won't be printed until more stuff comes in.

And your printf example above is a very short thing. So try it, but with a formfeed instead of the EOT character.

Apart from that, I guess it's going to be possibly reading the manufacturers documentation, and if you are unlucky, that printer talks some proprietary protocol, and they provide a Windows driver for you. (Good luck getting such a Windows driver work on any Unix-like system...)

  Johnny

--
Johnny Billquist                  || "I'm on a bus
                                  ||  on a psychedelic trip
email: bqt%softjar.se@localhost             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


Home | Main Index | Thread Index | Old Index