Applescript

bookem

danno
I'm kind of new to applescript, but if someone could tell me why this won't run I'd be grateful. It's supposed to remove all printers and install new ones:


------------------------------------------------------------
-- Definition
------------------------------------------------------------
-- Printer 1 Info
set p1 to "D22 A4 Lexmark"
set p1IP to "192.168.3.41"
set p1PPd to "/Library/Printers/PPDs/Contents/Resources/en.lproj/D22 A4 Lexmark"
-- Printer 2 Info
set p2 to "D22 A3 Lexmark"
set p2IP to "192.168.3.42"
set p2PPd to "/Library/Printers/PPDs/Contents/Resources/en.lproj/D22 A3 Lexmark"
-- Printer 3 Info
set p3 to "Bureau Colour"
set p3IP to "192.168.3.49"
set p3PPd to "/Library/Printers/PPDs/Contents/Resources/en.lproj/Bureau Colour"
-- Create lists of Printers, IP's, and PPd's
set pList to {p1, p2, p3}
set pIPList to {p1IP, p2IP, p3IP}
set pPPdList to {p1PPd, p2PPd, p3PPd}
set pDefault to ""
------------------------------------------------------------
-- Determine default printer via Computer Name
------------------------------------------------------------
set compName to do shell script "hostname"
if compName contains "D22" then
set pDefault to item 1 of pList
end if
------------------------------------------------------------
-- Action
------------------------------------------------------------
if pDefault is not "" then
-- delete printers
repeat with i from 1 to (length of pList)
set pDel to item i of pList
try
do shell script "lpadmin -x " & pDel
end try
end repeat
--define printer queues
repeat with i from 1 to (length of pList)
set pAdd to item i of pList
set pIPAdd to item i of pIPList
set pPPdAdd to item i of pPPdList
try
do shell script "lpadmin -p " & pAdd & " -E -v lpd://" & pIPAdd & " -P '" & pPPdAdd & "'"
end try
end repeat
--select default printer queue
do shell script "lpoptions -d " & pDefault
end if
------------------------------------------------------------
 
Back
Top