Print from shell to HP wireless printer

I've been having trouble printing to my HP wireless (P1102W) printer from either of my 2 Macs. As a developer I spend a lot of time in the shell (bash) and have been quite happy with the command-line tools available. One of things I would like to do is print from the shell - either interactively or from a shell script.


The only ways I know how to do this involve using 'lp' or 'lpr' and I'm sure they work the way they are supposed to. Except apparently if you try to print to an HP printer like mine. It DOES print fine from any other applications.


When I send a print job to the printer from my Macbook Air shell or the iMac shell, a window pops up on my iMac telling me to load paper in the manual feed tray and press 'Enter'. When I press 'Enter' it prints the job. I'm trying to avoid this if possible.


Example:


grep '006.' music.trxt | lp


Email to HP Support came back with this:

"We are sorry to let you know that HP Printers are designed to print from Graphical User Interface applications. For example, the applications from which you can select File-> Print to open a print window for further options. So you are able to print from the other applications. Regarding printing from the shell, we do not have the required expertise since this directly deals with the MAC operating system. Hence, I would request you to contact the Apple support team for more information."


Hence my posting here.


Does anyone have any similar problems?


Have you found a work-around?


Is there a way to insert a form-feed or carriage-return on the command line as part of the print command? I've tried using the Ctrl-V - insert_a_command trick but no joy.


I love my iMac but this is driving me crazy. Thanks for any suggestions / help.

iMac, Mac OS X (10.7.5), HP P1102W wireless

Posted on Mar 17, 2014 2:11 PM

Reply
19 replies

Mar 17, 2014 6:24 PM in response to mouthbreather0

I have an HP printer (4280) connected to an Airport Extreme that I can print to from the command line with no problem.


Some background, has this ever worked for you? Has anything changed? Does it work as expected from the GUI?


What does lpstat -p -d show (it should give you all printers and the system default) does more then one printer or device show up? What does lpq show?


lpoptions -l wil give all the options set on the default printer. You can select which printer to examine also. Look for the Paper Source option.


I'm thinking that you mat have separate queues, one for continuous printing and one for single sheets. Did you do anything extra or special when setting up CUPS?


It's been a long time since I setup printers and queues so I'm afraid this is all I;ve got right now.

Mar 17, 2014 6:43 PM in response to etresoft

Hello and thanks for the suggestion. I haven't tried CUPS-PDF but I did take a look at the link. From what I can understand it creates a PDF which is not quite what I want. I can create a PDF from the shell by doing:


man -t ls > ls .ps

open ls.ps


Preview will convert the PostScript to a PDF.


I have been looking at GutenPrint to see what it can do.


All I really want is getting lp or lpr to work with my HP printer. I may end up having to get a different printer.

Mar 17, 2014 7:10 PM in response to Frank Caggiano

Hi Frank,


No, I have not tried Airport but have heard about it. Here is what some of your suggestions show:


lpstat -p -d

printer HP_LaserJet_Professional_P_1102w is idle. enabled since Mon 17 Mar 21:36:05 2014

Ready to print.

system default destination: HP_LaserJet_Professional_P_1102w


lpq

HP_LaserJet_Professional_P_1102w is ready

no entries


lpoptions -l

PageSize/Media Size: *Letter Legal A4 Executive 8.5x13Custom A5 A6 B5JIS 16K195x270mm 16K184x260mm 16K197x273mm Postcard DoublePostcard Env10 Monarch EnvISOB5 EnvC5 EnvDL Custom.WIDTHxHEIGHT

Duplex/2-Sided Printing: *None DuplexNoTumble DuplexTumble

InputSlot/Media Source: *Manual

MediaType/Media Type: *Paper Light60-74g Mid-Weight96-110g Heavy111-130g ExtraHeavy131-175g TransparencyPaper LabelsPaper LetterheadPaper EnvelopePaper PreprintedPaper PrepunchedPaper ColorPaper BondPaper RecycledPaper RoughPaper VellumPaper

pjlDensity/Print Density: 1 2 *3 4 5

pjlJamRecovery/Jam Recovery: True *False

Resolutions/Resolution: *600x400dpi 600x600dpi

EconoMode/Economode (May Save Toner): True *False


You mention setting up CUPS but I don't recall doing that. Is that something that needs to be done?


Trying to keep things as simple as possible here if I can.

Mar 17, 2014 7:53 PM in response to mouthbreather0

I believe this


InputSlot/Media Source: *Manual


is your problem . for my Hp it shows as


HPPaperSource/Source: *Tray1


I'm fairly sure the two options refer to the same thing, where to get the paper from. Your printer is set to manual feed (which is what you are seeing) while mine is feeding from the paper tray.


If you look a the man page for lpoptions you can see how to set/change options. you might try playing around with that and see if it is possible to switch it to the tray.

Mar 17, 2014 8:14 PM in response to Frank Caggiano

I think you are on the right track. Just tried this:


lp -o HPPaperSource/Source=*Tray1 music.txt

request id is HP_LaserJet_Professional_P_1102w-327 (1 file(s))


but stil got the window popping up and had to hit Enter.


Not sure my syntax is correct for setting options. I've been reading the CUPS documentation to figure it out. If you have a suggestion ...?

Mar 17, 2014 8:23 PM in response to mouthbreather0

Yeah it's been a while.


Pretty sure the asterisk (*) is not part of the option. lpotion uses it to show which option is set, so I'd try that again without it.


You might also want to try setting it permanently with lpoption. This way you can check to see if the option as reported by lpoption has changed.


And of course there is no guarantee that the continuous feed option for that printer is tray1, could be something else (though tray1 seems a good place to start) and I have no idea where you would even begin to look for that info. 😟

Mar 17, 2014 8:44 PM in response to mouthbreather0

Good news and bad news:


With this as one option for my printer

ColorModel/Color Model: *RGB RGBW


This command

lpoptions -d HP_Deskjet_F4200_series -o ColorModel=RGBW


does change the lpotion output to

ColorModel/Color Model: RGB *RGBW


Notice the asterisk switched from RGB to RGBW


The bad news is if the option as reported by lpoption only has one setting it can;t be changed (at least I wasn;t able to). So in my case the paperfeed is

HPPaperSource/Source: *Tray1


and no matter what I tried I could not switch it to anything else.


So even if this is the source of your printers behavior there may not be anything you can do about it, at least from this point.


It is odd that the printer would only have a manual feed option as reported by CUPS. The printer does work normally from the GUI, correct? And there are no switches/settings on the printer for this?


Something else to try, as a test, is to connect the printer directly to the system and see if anything changes. I know with my printer hooked up through the Airport I cannot get to the ink levels and such or run any maintenance commands. I have to directly connect it to do that.


Sorry I don;t have more,


regards

Mar 18, 2014 6:25 AM in response to Frank Caggiano

That is very interesting, especially about my HP only having 1 option for InputSlot/Media Source: *Manual. On the other options there are several other choices. My attempts to change that obviously would not work.


That is probably what is the crux of the matter. I did try connecting the printer directly with USB but same results.


Bottom line is the printer does not seem to be configured for anything other than Manual feed (as per the HP email). I can live with the annoying 'feature' of having to hit Return on my other computer since it's only across the room but I would not recommend this printer in an office environment where it is shared by a few other offices - especially if the printer is off on another floor.


Thank you Frank and others who have put time and thought into this problem.

Practice safe hex 🙂

Mar 18, 2014 6:46 AM in response to mouthbreather0

The idea I have is to make a new printer in System Preferences, call it TermPrinter or whatever and set it to use the generic driver rather then the HP Driver.


I tired that here here with my printer (with only the one feed option) and when I looked at the new printer with lpoptions it had multiple feed options. I didn't have time to actually see if changing them would affect the print job (saw your last post) but it would be something to explore.

Mar 18, 2014 9:23 AM in response to mouthbreather0

One other thing (I think this is really the last other thing!) looking at the specs for the printer and the options you got from lpotions this one



Duplex/2-Sided Printing: *None DuplexNoTumble DuplexTumble


stands out. You might to try different settings of this (using the current setup with the HP driver) to see if it changes the paper fees of the printer.


Thsi is the entry in the specs that makes me recommend the above

User uploaded file


Worth a shot anyway

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Print from shell to HP wireless printer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.