[cups.general] Need help extracting printer driver name from ppd files

Johannes Meixner jsmeix at suse.de
Fri Jul 13 02:54:55 PDT 2012


Hello,

On Jul 12 18:23 Matt Broughton wrote (excerpt):
> In article <41576-cups.general at news.easysw.com>,
> Helge Blischke <h.blischke at acm.org> wrote:
>> Jeep Guy wrote:
>>>> Jeep Guy wrote:
>>>>
>>>>> Without going into too much detail, I have a few groups of HA print
>>>>> servers in dev, QA, Prod environments and I need to keep the configs in
>>>>> sync.  I am writing a perl script that will extract most of the printer
>>>>> info from the printers.conf file and dump it to a semi-colon delimited
>>>>> file.  I intend to use this file later to rebuild the basic printer
>>>>> configs on other systems using the lpadmin command.
>>>>>
>>>>> The problem that I am having is that I do not know how to get the print
>>>>> driver to be used with the lpadmin command.  I want to add the printers
>>>>> as follows:
>>>>>
>>>>> lpadmin -L <location> -D <description> -p <Printer Name> -v <device
>>>>> URI> -m <printer driver> -E
>>>>>
>>>>> I can get everything I need from the printers.conf file except for the
>>>>> <printer driver>.  It looks like the /etc/cups/ppd/<Printer Name>.ppd
>>>>> conf file should hold what I am looking for but I don't know if that is
>>>>> true or if so which variable I should be looking for in that file.
>>>>>
>>>>> Would someone knowledgeable please chime in and let me know where to
>>>>> get the printer driver to plug into the lpadmin command?
>>>>>
>>>>> Thanks.
>>>>
>>>> Yes, the /etc/cups/ppd/<printername>.ppd file *is* the PPD associated
>>>> with the <printername> and reflects the default preferences (like default
>>>> page size etc.) you configured either using the web interface or the
>>>> lpadmin command.
>>>> The problem is that there is - as far as I know - no information abour
>>>> the source directory the PPD has been installed from. That means your
>>>> Perl script needs to copy the PPD from the /etc/cups/ppd directory to
>>>> some globally accessible place (e.g. a NFS accessible directory).
>>>>
>>>> Helge
>>>
>>> Thanks Helge,
>>>
>>> In that case what do I supply to the lpadmin command for the <printer
>>> driver> option?
>>
>> the full (absolute) path to your copy of the PPD.
>
> Which, I believe, needs the -P option used instead of the -m option.
>
> lpadmin -L <location> -D <description> -p <Printer Name> -v <device URI>
> -P <printer driver> -E

The "MakeModel" value in /etc/cups/printers.conf matches the "NickName"
value in the PPD file and that is what could be used to "grep" in the
output of "lpinfo -m" to find a matching template PPD file in any
sub-directory in /usr/share/cups/model/.

If a matching template PPD file is found one can use the value in the
first column of the "lpinfo -m" output for the -m option in lpadmin.

Something like:
---------------------------------------------------------------------------
# grep ^MakeModel /etc/cups/printers.conf
....
MakeModel HP LaserJet 1220 Foomatic/ljet4
....

# lpinfo -m | grep 'HP LaserJet 1220 Foomatic/ljet4'
HP/LaserJet_1220-ljet4.ppd.gz HP LaserJet 1220 Foomatic/ljet4

# lpadmin ... -m HP/LaserJet_1220-ljet4.ppd.gz ...
---------------------------------------------------------------------------

But this way only works by chance because one another machine there
might be no matching template PPD file in /usr/share/cups/model/
and
this way only works partially because the template PPD file in
/usr/share/cups/model/ does not have the printer device specific
default settings (e.g. so that the PageSize matches the paper
that is actually loaded in the printer device) as the PPD file
in /etc/cups/ppd/ has so that the specific default settings
would have to be explicitly set via something like:
# lpadmin ... -o PageSize=A4 -o Resolution=600x600dpi ...

But even when using the PPD file in /etc/cups/ppd/ it may not work
in any case:

A PPD file may reference a printer driver program via an entry like
*cupsFilter: "application/vnd.cups-postscript ... driver-program"

But one another machine there might be no such driver program
installed so that you must check your PPD files whether or not
you need printer driver programs and make sure you have them
plus all what they need to run (e.g. libraries, other binaries
like Ghostscript and so on...) installed on the other machine.

Only if you have only PostScript printers and if you use them only
in their generic PostScript mode (i.e. without any driver program),
the PPD file in /etc/cups/ppd/ is sufficient.


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH -- Maxfeldstrasse 5 -- 90409 Nuernberg -- Germany
HRB 16746 (AG Nuernberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendoerffer





More information about the cups mailing list