This is on OS X 10.8. I want to be able to arbitrarily pull the configuration for a particular printer, so I can use it in a package-creation script. The script (not mine) uses

/usr/sbin/lpadmin -p "$printername" -L "$location" -D "$gui_display_name" -v "$address" \
-P "$driver_ppd"

to set up a new printer.

If I supply $printername on the system I'm pulling from, I can get $location and $address from lpoptions. But I can't seem to find a command that will give me $driver_ppd (which takes the form /Library/Printers/PPDs/Contents/Resources/HP LaserJet P4010_P4510 Series.gz).

I know it's available to the system because I can see it in the CUPS web interface under that printer.

  • Try parsing the config file, perhaps? – Faheem Mitha Jul 22 '14 at 14:24
  • Thanks @FaheemMitha. Unfortunately, the only config file I can find (/etc/cups/printers.conf) spits out the same information as lpoptions, i.e. no driver location. Nothing else in /etc/cups seems to have it either. – arthurlewis Jul 23 '14 at 18:53
  • On my system (Debian wheezy), the PPD files are stored as /etc/cups/ppd/printername.ppd. Assuming a similar schemes holds on other systems, you really just need the printer name, which you can get from /etc/cups/printers.conf. This appears to be in XML format, so you could probably use some suitable XML parsing tool. – Faheem Mitha Jul 23 '14 at 21:20
  • Hmm. While /etc/cups/ppd/$printername.ppd does have all the information I need (it's a copy of the driver file with options tweaked), that file is only present after the printer hass been installed. I was looking for a way to run a script on a system where the printer isn't installed yet, without having to also deliver the ppd file. (The drivers would already be installed as a separate package.) That said, if I can't make that work, this might very well be the best workaround. Thanks! – arthurlewis Jul 24 '14 at 2:43
  • "I was looking for a way to run a script on a system where the printer isn't installed yet, without having to also deliver the ppd file." I doubt this is something that can be done automatically. Shall I go ahead and add my previous observation as an answer? – Faheem Mitha Jul 24 '14 at 7:44

On my system (Debian wheezy), the PPD files are stored as /etc/cups/ppd/printername.ppd. Assuming a similar scheme holds on other systems, you really just need the printer name, which you can get from /etc/cups/printers.conf. This file appears to be in XML format, so you could probably use some suitable XML parsing tool.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.