Printing problems: command-line print a file

I think there are three typical ways we generate print jobs:

  1. a system runs a process that results in a print job, then automatically sends it to a location that someone configured
  2. you're working on a document, and at some point, you click "Print" and select a printer
  3. you have files on your hard drive that you need to print

For this discussion, let's talk about the third scenario. What command do you use to print files? We have two options for you.

Using the Microsoft LPR

LPR is a term used with printing systems since the 1970s, possibly earlier. It means "line print remote" and if that isn't completely clear, let me add that it's an engineering term meaning "print this file over there." In the old days, printers that did both text and images were expensive, so most printers we used were text only, hence the term "line printer." Over time the same technology was used to send prints regardless of the printer.

Assuming you have a Windows command prompt, type this command:

lpr /?

If you get a response that begins with "Sends a print job to a network printer" you have the Microsoft LPR command installed. If not, search for "how to install lpr on <x>" where the last part is your version of Windows, for instance, "how to install lpr on windows 10"

The only arguments you need to be concerned about are the hostname or IP address of the computer (or printer) you are printing to, plus a queue name. Of course, you also need the filename.

To use the Windows LPR you would use a command similar to the following:

lpr -S -P

For instance,

lpr -S localhost -P hp4200 mydailyreport-0321.txt

Using the Brooks print program

We include a command-line print program with RPM Remote Print Manager® (RPM) called pylpr. You'll find it in the RPM install folder.

Go to that folder, typically "C:\Program Files\Brooks Internet Software\RPM" and type:

pylpr /?

Here you'll see a long list of command-line options.

pylpr has several distinct advantages over the Microsoft lpr:

  • unless you apply a registry hack, lpr is limited to printing only 13 files over a given period
  • lpr doesn't print more than one file at a time

Let me give you an example of how pylpr overcomes those limitations.

pylpr -n -p archive@localhost d:\testing\data\sample\*

This command prints the entire contents of the sample directory to the "archive" on my local computer and shows me the name of each file as pylpr sends it.

I don't know if there is a limitation is on the number of files pylpr can send at a time. The most I've sent at once is 132 thousand.

You are welcome to use pylpr on any computer where RPM is licensed. If we can answer any questions you may have about command-line printing, please leave a comment. Thank you!