Printing from the Command Line
Dave writes with the following question:
I have a Powerbook with a wifi inkjet printer. I would like to copy a printer file made on my Amiga to the inkjet, but the Amiga only has a parallel port. I’ve transferred the file to my Mac but can’t copy it by dragging to the print center. I get an error message saying “there is no default application.” Can I copy the file to the printer port by command line?
On the Amiga, I go to the command line interface and type: “copy ‘filename’ par:” and it works. On a PC, I would type: “copy /b ‘filename’ lpt1″. Is there a similar command on the Mac Command Line?
Dave: First, I don’t know what kind of format the file you’re getting from the Amiga is. If it’s a text file, then you can easily work with it on the Mac. You should be able to open it with any text editor, such as TextEdit or BBEdit. If not, then you’ll need to find out how to save the file as a text file on the Amiga.
Printing text files from the command line on Mac OS X is a snap. You use the lp command like this:
lp file1 file2 ...
where you can have as many files listed after the lp command as you want.
This is very useful when you want to print a lot of files in a folder. Say you want to print all the text files in a folder; you can use the * wildcard like this:
lp *.txt
This prints every file whose name ends with .txt to the default printer.
But it gets better. While the lp command can’t print every file (it won’t print .doc files, for example) it can print many different types of files. It can handle text files, PDFs, and many image formats, such as gif, jpeg and tiff. I find it especially useful when I have a lot of PDFs to print (such as when I’m working on page proofs from a book); I just use the lp command to print them all, instead of opening them in Preview and printing each one individually.
Naturally, there is a full chapter in my book The Mac OS X Command Line: Unix Under the Hood about printing from the command line.
Read more articles in this category: Mac OS X Command Line
Posted: 12/8/2004 by kirk | Filed under: Apple & Mac OS X | 2 Comments »
Additionally, if you have an Appletalk printer, as I do (it’s an HP Laserjet
2100TN, before you assume that it’s some ten year old clunker!) then there
are some nice command line utilities for these too. The first is the oddly
named “at_cho_prn” which lets you choose a default AppleTalk
printer. You can use “atprint” to actually print using AppleTalk. Hope
that helps!
—
You’ve got questions? I’ve got answers: Ask Dave Taylor!
The file that I’m sending is a PCL3 printer file, in binary I believe. So
it looks like gibberish in a text editor. It’s meant to be sent directly to
the printer.
I’ll try the "lp" command and see if it works.
My other printer is a Laserjet 4m connected via Appletalk. It prints very
slowly from the Mac, which is why I continue to use the Amiga for text
printing on the laser. The Amiga prints Postscript text files to the laser
some six times faster than the Mac. Graphic images are slower of
course.
Thanks,
Dave