Skip to content

Instantly share code, notes, and snippets.

@krispayne
Last active May 9, 2017 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krispayne/33d7d5034b925cc2e279f1b86f7f9483 to your computer and use it in GitHub Desktop.
Save krispayne/33d7d5034b925cc2e279f1b86f7f9483 to your computer and use it in GitHub Desktop.
Extension attribute to determine the installed printer driver version for a given Xerox printer model.
#!/bin/bash
# Determine the printer driver version using lpinfo
# I got the printer information by running:
# [kris@Kris-MacBook-Pro ~]$ lpinfo --make-and-model "7225" -m
# Library/Printers/PPDs/Contents/Resources/Xerox WorkCentre 7225.gz Xerox WorkCentre 7225, 3.123.0
# [kris@Kris-MacBook-Pro ~]$
#
# for an HP I have I used:
# [kris@Kris-MacBook-Pro ~]$ lpinfo --make-and-model "hp laserjet p4010" -m
# Library/Printers/PPDs/Contents/Resources/HP LaserJet P4010_P4510 Series.gz HP LaserJet P4010 Series
# [kris@Kris-MacBook-Pro ~]$
# which did not return a version. YMMV. Printer driver makers DGAF.
printer="Xerox WorkCentre 7225"
driverversion=$(lpinfo --make-and-model "${printer}" -m | sed -n -e 's/^.*, //p')
if [[ ${driverversion} ]]; then
result=${driverversion}
else
result="Not Installed"
fi
echo "<result>$result</result>"
@krispayne
Copy link
Author

krispayne commented May 9, 2017

This assumes a structure of /path/to/driver Driver Name, version which isn't always the case:

Library/Printers/PPDs/Contents/Resources/HP Business Inkjet 2250.gz HP Business Inkjet 2250 PS - Ver 1.6
Library/Printers/PPDs/Contents/Resources/HP Business Inkjet 2280.gz HP Business Inkjet 2280 PS - v1.0
Library/Printers/PPDs/Contents/Resources/hp business inkjet 2300.gz HP Business Inkjet 2300 PS v3010.107
Library/Printers/PPDs/Contents/Resources/HP Business Inkjet 2600.gz HP Business Inkjet 2600 PS -RC-2.0
Library/Printers/PPDs/Contents/Resources/HP Color LaserJet CM1312 MFP Series.gz HP Color LaserJet CM1312 MFP Series
Library/Printers/PPDs/Contents/Resources/HP Color LaserJet CM1312 MFP Series Fax.ppd.gz HP Color LaserJet CM1312 MFP Series. Fax
Library/Printers/PPDs/Contents/Resources/Xerox Phaser 7500DT.gz Xerox Phaser 7500DT, 3.123.0

This works for my purpose (EA for Xerox driver) but if you want to do more sed/awk magic to make it "universal" be my guest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment