Printing from Cygwin

I use Cygwin quite a lot, but I never tried printing from it until last night. I had assumed it would be difficult; it’s not. On Unix/Linux systems, you can print by piping commands to lpr (i.e. “local printer”). So, for instance, printing the results of ls -a (list all files in the current directory) to your printer (rather than the terminal window) would go like this:

ls -a | lpr

Now, on Cygwin, you’ll get an error if you try this. Lpr won’t know which printer to target. Luckily, lpr has a -d option for setting the destination. You can define that destination as //machineName/printerName. If your printer name has spaces in it, just put in quotes:

ipconfig /all | lpr -d //martinj/”lexmark t620″

The above will pipe the results of ipconfig (a DOS app, hence the “/all” format of the “show all” argument, rather than the more Unix-ish “-a”) to the local printer, as defined by the -d option.

The above has been handy in documenting my current network outages. Grrrr!

Leave a Reply

Your email address will not be published. Required fields are marked *