I wrote a script to update all of the office printers from Appletalk to IP Printing. I’d like to know if it’s possible to wrap it up in an installer package so I could send it to all of the machines via Apple Remote Desktop.
Here is the script in case any of you find this useful…
log (do shell script "date")
set lj2100 to "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP\\ LaserJet\\ 2100\\ Series.gz"
set lj2200 to "/Library/Printers/PPDs/Contents/Resources/en.lproj/HP\\ LaserJet\\ 2200.gz"
set lj2300 to "/Library/Printers/PPDs/Contents/Resources/en.lproj/hp\\ LaserJet\\ 2300.gz"
set lj4600 to "/Library/Printers/PPDs/Contents/Resources/en.lproj/hp\\ color\\ LaserJet\\ 4600.gz"
--update printers:
--[edit: snip!]
--[ex: ] updatePrinter("Karen's_Printer", "192.168.100.153", lj2300)
--notify user of changes:
display dialog "Printer settings have changed. Please make sure your default printer is set correctly." buttons {"OK"} default button 1 with icon 2
tell application "Printer Setup Utility"
activate
end tell
----SUBROUTINES:
--updatePrinter: updates a printer from appletalk to IP Printing given the name, IP and PPD path
on updatePrinter(pname, printerIP, PPD)
set success to true
try
do shell script ("lpadmin -x " & doublequote(pname))
on error err
set success to false
if err is "lpadmin: delete-printer failed: client-error-not-found" then
log (" not present: " & pname)
else
log (" * on remove " & pname & ": " & err)
end if
end try
if success then
log (" removing appletalk printer " & pname)
log (" adding as IP printer on " & printerIP)
try
do shell script ("lpadmin -p BINPS_on_" & printerIP & " -D " & doublequote(pname) & " -v lpd://" & printerIP & "/lpd/ -P " & PPD & " -E")
on error err number num
display dialog "Failed to add " & pname & ": " & err & {return} & "Error #" & num
end try
end if
end updatePrinter
on doublequote(str)
return "\"" & str & "\""
end doublequote
on log (str)
set logpath to "~/.printer_update.log"
do shell script ("echo " & doublequote(str) & " >> " & logpath)
end log
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)