Drucker per Skript / Command Line auf Mac OS X anlegen / löschen

neuen Drucker anlegen
#!/bin/bash
# printerhostname.company.lan
# Xerox DocuColor 4 LP PS


# Tests to see if printer exists - sidesteps a variable scope issue
# Requires the printer name as a parameter.  Returns 1 if the printer exists.
function printerExists() {
  if [ $# -ne 1 ]; then
    echo "Incorrect parameters"
    return 0
  else
    lpstat -a | awk '{print $1}' | while read printer
    do
      if [ $1 = "${printer}" ]; then
        return 1
      fi
    done
  fi	
}


# Printer Name cannot Include any spaces
prName="printerhostname"
# User friendly printer name"
prDescription="printerhostname-description"
# Location
prLocation="where i am"
# IP Address of printer
prAddress="printerhostname.company.lan"
# PPD Filename... assumes it is installed on machine
prPPD="Xerox DocuColor 4 LP PS.gz"
# Sharing
prSHARE="0"


#Test If Printer is already installed
printerExists $prName
prExists=$?

if [ $prExists -eq 1 ]; then
  echo "Printer already exists. Skipping: \"$prName\""
else
  # Add Printer Command 
  lpadmin -p "${prName}" -D "${prDescription}" -L "${prLocation}" \
  -E -v lpd://"${prAddress}" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj//$prPPD" \
  -o "printer-is-shared=$prSHARE" -o "EFOption_A3OverTray=True" -o "EFOption_HCI=True" -o "EFOption_Disk=False"\
  -o "InstalledMemory=192MB" -o "ColorModel=CMYK" -o "EFColorCRDText=Photographic" \
  -o "EFColorCRDGraphics=Photographic" -o "EFColorCRDImages=Photographic" -o "EFColorHTText=Detail"
fi

 

Drucker Optionen auslesen
den gewünschten Drucker als Standartdrucker definieren
lpotions -d printer_name
lpoptions -l

 

Alle Queues löschen
#!/bin/bash

lpstat -p | awk '{print $2}' | while read printer
do
  echo "Clearing Queue for Printer:" $printer
  lprm - -P $printer
done

 

alle Drucker löschen
#!/bin/sh  
for printer in `lpstat -p | awk '{print $2}'`; do 
    echo Deleting $printer lpadmin -x $printer
 done

 

alle installierte Drucker auflisten
lpstat -p

 

aktuellen Druck Job zeigen
lpstat -o Printer_Name

 

den aktuellen Druck Job löschen
lprm - -P Printer_Name

 

Drucker hinzufügen / löschen / Papierstau aufheben ohne Adminrechte
sudo dseditgroup -o edit -n /Local/Default -a everyone -t group lpadmin

 

20. Januar 2016 5904 webadmin  OS X  
Total 1 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Add A Knowledge Base Question !

+ = Verify Human or Spambot ?

Add A Knowledge Base Question !

+ = Verify Human or Spambot ?