[HN Gopher] Bye CUPS: Printing with Netcat
___________________________________________________________________
Bye CUPS: Printing with Netcat
Author : r3trohack3r
Score : 40 points
Date : 2021-08-03 22:03 UTC (57 minutes ago)
(HTM) web link (retrohacker.substack.com)
(TXT) w3m dump (retrohacker.substack.com)
| deeblering4 wrote:
| Have fun printing a shipping label from your phone using Netcat.
| herpderperator wrote:
| How would you get an application, such as Firefox or Chrome, to
| know to use netcat to print?
| Evidlo wrote:
| Choose Jetdirect/Appsocket in the printer add menu and it will
| do the same thing.
|
| There is nothing magic about netcat. You are just dumping
| Postscript/PDF data on a TCP port the printer is listening on.
| r3trohack3r wrote:
| Oh fascinating. If I use the system dialogue, I can choose
| the application to print to. There is an `lpr` option, and I
| can specify the application it invokes in a "Command Line"
| field.
|
| I can put `nc [printer_ip] 9100` there and it will just
| print. I just printed your comment this way.
|
| That's cool! Thank you for teaching me something!
| jkingsman wrote:
| You'd need to set up a system printer using the
| JetDirect/socket protocol, then you could print via normal
| print dialog.
| r3trohack3r wrote:
| Today I: CTRL+P -> Save to PDF.
|
| If I want to print multiple pages per sheet: Open PDF in
| Firefox, CTRL+P -> Save to PDF and configure the document. You
| can also pipe through `gs` to do this.
|
| For _huge_ documents (100s of pages), I'll pipe through `gs`
| first to do the pdf->ps conversion on my laptops CPU. The
| printer can do it, it just takes a lot longer.
| mongol wrote:
| Found some info here
|
| https://en.wikipedia.org/wiki/JetDirect#Protocols
| turminal wrote:
| Convenient, but not very secure
| jim-jim-jim wrote:
| Hah. I had a similar moment of enlightenment with FreeBSD when
| somebody explained that you can just cat a wav file into
| /dev/audio (or /dev/dsp? forget the exact name). And that you can
| produce white noise by catting /dev/random to the same
| destination. With no barrier to the sound card like that, I was
| free to experiment with programming dfferent noise algorithms and
| figuring out how digital audio works. I eventually did things the
| proper way with OSS and finally sndio on OpenBSD, but direct,
| universal interfaces like files invite that initial exploration
| and help you get things done quick and easy.
|
| netcat is also a secret weapon around the house. My girlfriend
| runs macOS, but it's way more reliable to just nc files to each
| other over wifi than deal with all the cloud and airdropping
| bullshit.
| terinjokes wrote:
| This is how this Hackernews printed several pages worth of the
| plaintext representation of a PDF on an office printer a few
| years ago before figuring out how to cancel the job.
| Arnavion wrote:
| So how did you cancel it? I assume killing the nc process
| wasn't enough because it had buffered the whole file, so you
| had to do it at the printer?
| squarefoot wrote:
| Happens all the time when something goes wrong, like
| malformed files, wrong driver loaded, etc. All printers have
| an internal buffer, so when one goes crazy printing pages of
| gibberish, the only solution is to kill the job directly on
| the printer, or turn it off asap, then go to the computer and
| empty the print queue should something exist there as well,
| then do the same at the print server, if there is one. The
| point is that once a print is started, all buffer will
| eventually end up to the printer, so it's the 1st device we
| must stop and the last one to restart once we're sure no data
| to print is left between the application and the paper, that
| is, not before all spoolers have been emptied.
| dredmorbius wrote:
| If you have a single host, and a single printer, or your printer
| itself is both network-enabled _and_ can manage its own print
| spool, direct TCP /IP printing may indeed work for you.
|
| The value of CUPS is that it enables the CUPS-serving _computer_
| to run as a _print server_. This means not only print drivers
| (document format support --- typically plain text, Postscript,
| and one or more PDL (printer definition languages) & PCL
| (Printer Control Language), but status on the printer, queue
| management, job control, and access control. Note that if your
| printer is generally available on your local WiFi network, you
| might want to give more thought to that last element.
|
| If those are overkill for you and your printer Just Works with
| generated output, then yes, you can get by without the
| complexity.
|
| Note that you can also often telnet directly to the printer port.
|
| Be aware of what you're trading off, though, and whether or not
| you actually need what CUPS, or direct network access, offers.
| cbhl wrote:
| The CUPS web front-end also has rough edges; Apple maintains
| CUPS these days and OS X now ships with the web interface on
| :631 disabled.
|
| If you still need a print server, it can be well worth the
| extra $100 or so to buy a business-class printer with an IPP
| server in it, so that CUPS runs on a chip inside the printer
| instead of on a separate computer. (Generally anything that
| supports "Airprint" will do this, and also at the mid range you
| avoid the "printers whose ink cartridges are more expensive
| than the printer" zone.)
| dimitar wrote:
| Works on any OS (just tried macOS for example), but its not very
| convenient to set print options. Passed a jpg and it printed out
| the metadata.
| herpderperator wrote:
| I just tried this and while it worked, it was very slow. It takes
| a minute to start printing a page in a PDF, meanwhile nc is still
| hanging and sending the data, seemingly very slowly. The printer
| is constantly showing "Receiving Data" on its screen. The PDF is
| only 450KB.
|
| Edit: It took about 5 mins to print a 3-page document, with long
| pauses between each page.
| r3trohack3r wrote:
| I suspect it's the printer doing the pdf->ps conversion. I have
| a beefy printer, so only run into this for large documents. But
| I'll cat through `gs` then to `nc` to do the pdf->ps conversion
| locally, and it is much faster.
| herpderperator wrote:
| That makes sense. That's why you want to do print spooling on
| client devices, which run on extremely fast CPUs in
| comparison. I guess that is why we don't send documents
| directly to printers.
| voidmain0001 wrote:
| YMMV as the printer needs to support PCL/PDL and not all HP
| network servers have it built-in. HP chose to save some money by
| making dumb network cards that forced the PCL/PDL rendering on
| the Windows computer which made using Linux difficult.
|
| http://danieru.com/2013/06/06/what-is-port-9100-how-to-print...
|
| While you're at it you may as well try out the printer exploit
| kit https://github.com/RUB-NDS/PRET
| marcodiego wrote:
| I once did something similar to that on my previous job. A
| colleague came by asking who printed several pages of garbage.
| Me: "Sorry, I just inferred every reputable printer supported
| postscript". The problem: the job was an outsource for a pinter
| vendor. They obviously did not like my comment.
| corbet wrote:
| FWIW, the Internet Printing Protocol (and IPP Everywhere in
| particular) make printer setup in CUPS far, far easier, but
| distributors seem reluctant to encourage it. I wrote about my
| experiences with IPP back in June
| (https://lwn.net/Articles/857502/). I expect to never have to
| hassle with printer drivers again...
| ggm wrote:
| CUPS exist because not all printers are HP.
|
| Magic in printing is still an arcanum. PPD files. Windows 10 as a
| print server. (some print devices are not networked)
|
| Prelude files. in-printing logic like line reversal, density
| adjustments for photos. Double sided printing meta-signalling,
| n-up..
|
| "oh, I don't need that stuff" fine, fine, nc is going to work for
| you, at the end of a bumpy road to a printer which supports it.
| And, right up until its 2am, you want to colour print that late
| birthday card for your favourite aunt, and the printer is stuck
| on nc...
| TacticalCoder wrote:
| I used to do this at home all the time (from Linux though):
| networked printer with its own IP address and then good old
| netcat. I'd do it with PostScript files and send them to HP
| LaserJet 4M+: not only do these beauties speak PostScript
| natively, they can also be made to display the infamous "PC LOAD
| LETTER" message.
|
| I'd try to find these printers used then I'd upgrade them: more
| RAM, more fonts, adding a network card inside the printer etc.
|
| I still have several of these printers in a garage, some of them
| have printed more than 300 000 pages. They probably still work:
| some things were that good back then.
|
| And, yup, there's something feeling magical when netcat'ing a .ps
| file (or another format) directly to the printer.
| [deleted]
| mackman wrote:
| My first introduction to the internet was downloading Magic the
| Gathering card lists as postscript files via FTP and then FTPing
| them to a postscript printer. Would have been 1994 and they were
| some sort of Sun machine at LMU. Internet has been all downhill
| since then.
___________________________________________________________________
(page generated 2021-08-03 23:00 UTC)