View unanswered posts | View active topics It is currently Tue May 21, 2013 6:04 am



Reply to topic  [ 16 posts ]  Go to page: 1, 2  Next
 AppleScript changes in Snow Leopard 
Author Message
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6651
Location: Austin, Texas
Post AppleScript changes in Snow Leopard
All,

If you're a heavy AppleScript user, I highly suggest you read the AppleScript Release Notes for 10.6. AppleScript has apparently undergone some significant changes. I think most of these are for the better: better support for scripts in threads, improved security, etc. As some have already found, however, there are some changes that are gonna cause some issues (date formatting, text processing, scripting addition incompatibilities, etc.)

Just FYI...

_________________
Jay (Indigo Support)
Image


Mon Aug 31, 2009 2:57 pm
Profile WWW

Joined: May 27, 2007
Posts: 689
Location: NC
Post 
Ya know? I'm staying as far away from Snow as I do Vista.
Its going to break more stuff then fix for me.
(or cause $600 of upgrades for a $30 OS)


Mon Aug 31, 2009 6:18 pm
Profile

Joined: Sep 24, 2005
Posts: 502
Post 
that is very good to know, thanks jay. still haven't upgraded server to 10.6. mostly because my install packages failed when upgrading over the 10.5.8 currently running for some reason. i've counted myself lucky since i don't have days to debug scripts and stuff at this point.

ars writer john siracusa has a great, in depth - 23 pages - evaluation of SL, especially good descriptions of grand central and some other new tech in 10.6:

http://arstechnica.com/apple/reviews/20 ... x-10-6.ars


Tue Sep 01, 2009 3:54 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6651
Location: Austin, Texas
Post 
dtich wrote:that is very good to know, thanks jay. still haven't upgraded server to 10.6. mostly because my install packages failed when upgrading over the 10.5.8 currently running for some reason. i've counted myself lucky since i don't have days to debug scripts and stuff at this point.

ars writer john siracusa has a great, in depth - 23 pages - evaluation of SL, especially good descriptions of grand central and some other new tech in 10.6:

http://arstechnica.com/apple/reviews/20 ... x-10-6.ars


Yeah, I've only plowed my way through the first 5 pages so far... ;)

_________________
Jay (Indigo Support)
Image


Tue Sep 01, 2009 4:44 pm
Profile WWW

Joined: May 27, 2007
Posts: 689
Location: NC
Post 
dtich: Great info!!!!!!

Nice to see a little inside trader stuff. (not like Apple really allows it, but its out and the NDA should be over)

(we don't have any post/user rating system here do we?_


Tue Sep 01, 2009 9:16 pm
Profile

Joined: Feb 26, 2007
Posts: 33
Post Re: AppleScript changes in Snow Leopard
What do we need to do to be able to run AppleScripts properly? I want to be able to get the status of a device and store it in a file. I am running this:
Code: Select all
tell application "IndigoServer"
   --  tell "Desk Light"
   if on state of device "Desk Light" = true then
      set prevstatus to "On"
      turn off "Desk Light"
   else
      set prevstatus to "Off"
   end if
end tell

tell application "Finder" to if not (exists (((path to desktop) as string) & "iTunesStatus.txt")) then
   try
      tell application "Finder"
         make new file at desktop with properties {name:"DeskLightStatus.txt"}
      end tell
   end try
end if

set the_file to (((path to desktop) as string) & "DeskLightStatus.txt") as alias

open for access the_file with write permission
set eof of the_file to 0
write prevstatus to the_file starting at eof as text
close access the_file


However, I get an error that I can't open the file with write permissions.

Apple says: For security reasons, in Snow Leopard most of the standard scripting additions no longer accept Apple events from other processes (or other machines); instead, the addition event handler returns a “privilege violation” error (-10004).

What do I need to do?

Thanks.


Sun Feb 21, 2010 2:35 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11689
Location: Texas
Post Re: AppleScript changes in Snow Leopard
I'm not getting that error. I tried your script from the Script Editor, as an embedded Indigo Execute AppleScript script, and as an attachment function. No problems with any of those 3. Are you sure the user under which the script is running has permissions to create the file in the path on your Mac?

_________________
Image


Mon Feb 22, 2010 5:52 pm
Profile WWW

Joined: Feb 26, 2007
Posts: 33
Post Re: AppleScript changes in Snow Leopard
I'm the only user on my Mac and I have administrator rights.


Mon Feb 22, 2010 6:03 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11689
Location: Texas
Post Re: AppleScript changes in Snow Leopard
How are you executing the script? Have you commented out various parts to figure out exactly what line is failing?
Does the file already exist on your system? Have you tried deleting it? Have you tried different file paths?

_________________
Image


Mon Feb 22, 2010 6:20 pm
Profile WWW

Joined: Feb 26, 2007
Posts: 33
Post Re: AppleScript changes in Snow Leopard
I saved the AppleScript as an application. When I run it, it gives an error when checking for a file which _does_ exist at the specified location. Then, when it tries to create a file at the same location (since it thinks it doesn't exist), it gets an error because the file exists. It doesn't make sense, but that's what's happening. I don't want to mess around with other locations until I can find out why this test isn't working. The notes about authority when running AppleScript under Snow Leopard have me worried that it won't be able to test the file at all. I'm not sure what else to do.


Mon Feb 22, 2010 9:09 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11689
Location: Texas
Post Re: AppleScript changes in Snow Leopard
Your script conditional that is checking for a file is looking for a file named iTunesStatus.txt, but you are creating and writing to a file called DeskLightStatus.txt.

_________________
Image


Mon Feb 22, 2010 9:40 pm
Profile WWW

Joined: Feb 26, 2007
Posts: 33
Post Re: AppleScript changes in Snow Leopard
Shooting myself in the head. :-)

That's what I get for copying from one script to another. Thanks. I'll fix it.


Mon Feb 22, 2010 10:03 pm
Profile

Joined: Dec 26, 2007
Posts: 486
Location: British Columbia
Post Re: AppleScript changes in Snow Leopard
Has anyone plow'd through the changes one might need to make in the Indigo usage arena?

This used to work as an embedded script:
if (value of variable "garageTemperature" is greater than 68) then
    turn on "GI10 FanGarageUp"
    log "GI10 FanGarageUp ON - temp is " & value of variable "garageTemperature"
else
    turn off "GI10 FanGarageUp"
    log "GI10 FanGarageUp OFF - temp is " & value of variable "garageTemperature"
end if

Now, since upgrade to Snow, it errors:
Error script error: Expected “,” but found “"”. (-2741)

This is at the first " encountered.

After finally getting Snow running I'd hate to have to step back again :-))

TIA

Edit: Found Matt's suggestion to wrap with
tell application "IndigoServer" / end tell
and that seems to work.
Had some "user" problems which gave me a false "not working" but was able to sort it out and all seems well at the moment.


Mon Mar 15, 2010 7:36 pm
Profile WWW
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11689
Location: Texas
Post Re: AppleScript changes in Snow Leopard
Note that Indigo variables are always stored and returned as strings. Therefore, you need to cast them to numbers before using them in conditionals against other numbers. Change conditionals like this:

Code: Select all
if (value of variable "garageTemperature" is greater than 68) then

to this:

Code: Select all
if ((value of variable "garageTemperature") as number is greater than 68) then

_________________
Image


Tue Mar 16, 2010 10:47 am
Profile WWW

Joined: Dec 26, 2007
Posts: 486
Location: British Columbia
Post Re: AppleScript changes in Snow Leopard
Thanks Matt.

Still needs the tell application "IndigoServer" wrap. Is that going to stay a requirement for Snow?

Just wondering if I should be digging into the scripts or just watch/wait for errors in the event log.

H.


Tue Mar 16, 2010 11:06 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page: 1, 2  Next

Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.