image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old August 25th, 2004, 05:26 AM
danno
 
Join Date: Aug 2001
Posts: 505
Thanks: 0
Thanked 0 Times in 0 Posts
bookem is on a distinguished road
Applescript

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
------------------------------------------------------------
__________________
MBP Core2Duo 2.33, iMac G5 1.8GHz, iPhone, PowerBook 12" 1GHz, AppleTV, MOTU 828, Logic Studio, Ableton Live 6.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 03:12 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.