Created
December 1, 2015 13:09
-
-
Save calum-github/24b0a54d04b885348c42 to your computer and use it in GitHub Desktop.
add printer drivers function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| locate_printer_driver(){ | |
| # $1 is printer_make $2 is printer_model | |
| driver_location=$(zgrep -i -E "${1}.*${2}" /Library/Printers/PPDs/Contents/Resources/*.gz | grep -v "Fax" | awk -F ":" '{print $1}' | head -1) | |
| if [ -z "$driver_location" ]; then | |
| echo $(date "+%a %b %d %H:%M:%S") "- *** Error *** Unable to locate PPD for make: $1 model: $2" | |
| echo $(date "+%a %b %d %H:%M:%S") "" | |
| echo $(date "+%a %b %d %H:%M:%S") " - If you are sure the driver (PPD) is installed for this printer then" | |
| echo $(date "+%a %b %d %H:%M:%S") " - please check you are specifying the correct model code" | |
| echo $(date "+%a %b %d %H:%M:%S") " - for your printer as it is listed in the PPD file." | |
| echo $(date "+%a %b %d %H:%M:%S") "" | |
| echo $(date "+%a %b %d %H:%M:%S") "- Defaulting to using the generic PPD. Your mileage may vary" | |
| driver_location="/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd" | |
| else | |
| echo $(date "+%a %b %d %H:%M:%S") "- Found PPD: $driver_location" | |
| fi | |
| add_printer "$printer_server_address" "$printer_queue_name" "$driver_location" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment