View unanswered posts | View active topics It is currently Wed Apr 23, 2014 11:32 am



Reply to topic  [ 45 posts ]  Go to page: Previous  1, 2, 3
 Xytronix Temperature Module AppleScript 
Author Message

Joined: Mar 17, 2010
Posts: 6
Post Re: Xytronix Temperature Module AppleScript
Tried copying over "URL Access Scripting.app" from 10.6.X -- no dice, finds the App now, but still doesn't work.


Wed Jul 20, 2011 6:19 pm
Profile
User avatar

Joined: Aug 19, 2007
Posts: 16
Location: Auberry, CA
Post Re: Xytronix Temperature Module AppleScript
Oh, that does suck! :evil: Mike, sorry you had to discover that the hard way! Ditching "URL Access Scripting.app" is going to kill many useful scripts and I see no work-around for the moment (any ideas Jay?). I always wait a while before updating to the latest OS. I may never update to Lion if this isn't resolved since it renders much of my hardware & software unusable.

Mike, I guess you'll need to restore the appropriately named "Snow Leopard" to keep your Greenhouse cool for now!

Stay cool 8) ,

Chris


Wed Jul 20, 2011 7:57 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 13239
Location: Texas
Post Re: Xytronix Temperature Module AppleScript
Agreed this is going to be a problem for multiple scripts. We are going to start looking for workarounds on this one tomorrow.

_________________
Image


Wed Jul 20, 2011 7:59 pm
Profile WWW

Joined: Sep 16, 2009
Posts: 95
Post Re: Xytronix Temperature Module AppleScript
Been using one of these non-stop in the datacenter at work for about 5-6 years, great devices.

-Chris


Wed Jul 20, 2011 11:21 pm
Profile
User avatar

Joined: Nov 18, 2008
Posts: 2253
Location: Berkeley, CA, USA
Post Re: Xytronix Temperature Module AppleScript
How about using curl?


Wed Jul 20, 2011 11:59 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 8357
Location: Austin, Texas
Post Re: Xytronix Temperature Module AppleScript
So, fortunately it's relatively simple to change your scripts to use the curl command rather than URL Access Scripting application. After doing some research and finding no suitable Lion replacement app (c'mon Apple), I converted the NOAA weather script ot use curl - it'll be included with the next releases of 4 and 5 but if you need a copy before then send me an email at indigo DASH support AT perceptiveautomation DOT com and I'll mail it to you.

Here's an example of the change:

Code: Select all
-- Using URL Access Scripting
set myFile to ((path to temporary items) as string) & "url_access_file.xml"
tell application "URL Access Scripting"
   download "http://www.nws.noaa.gov/data/current_obs/KATT.xml" to file myFile
end tell

-- Using curl
set myFile to (POSIX path of (path to temporary items)) & "curl_file.xml"
do shell script "curl -L " & "http://www.nws.noaa.gov/data/current_obs/KATT.xml" & " -o " & myFile

_________________
Jay (Indigo Support)
Image


Thu Jul 21, 2011 3:06 pm
Profile WWW
User avatar

Joined: Nov 18, 2008
Posts: 2253
Location: Berkeley, CA, USA
Post Re: Xytronix Temperature Module AppleScript
In the end, I have found curl to be more reliable. With URL Access Scripting I would get seemingly random connection errors, Curl also allows a lot better control over the connection - though, the man page is a bit daunting and getting the do shell script call right for complex curl commands can be a frustrating exercise in escaping and quoting. Another nice side benefit of curl is that you can easily test, and debug, the curl command from the shell (terminal).


Thu Jul 21, 2011 3:26 pm
Profile
User avatar

Joined: Aug 19, 2007
Posts: 16
Location: Auberry, CA
Post Re: Xytronix Temperature Module AppleScript
Essentially we're just trying to fix a single thing involving the lack of "URL Access Scripting" support in Lion. The rest of the AppleScript is debugged and has been working for years. AppleScript does have a "do shell script" functionality, so is there a way to use that to do whatever it is that you're doing with curl?


Thu Jul 21, 2011 7:53 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 13239
Location: Texas
Post Re: Xytronix Temperature Module AppleScript
Totally. Look at Jay's code above. He has an example that uses URL Access Scripting, then another example that does the exact same thing using curl. If you have problems getting it working doing a similar substitution, then post both the before and after code and we'll give it a look.

_________________
Image


Thu Jul 21, 2011 8:24 pm
Profile WWW
User avatar

Joined: Aug 19, 2007
Posts: 16
Location: Auberry, CA
Post Re: Xytronix Temperature Module AppleScript
Thanks guys! In the past I've used "do shell script" to extend AppleScripts capabilities so I was thinking it could be useful to do a little "lion Taming" magic but didn't know exactly how. I did a quick test yesterday with he "curl -L" command and it worked on the first try. Today I've had it running for the past few hours under Indigo 4 and OS X 10.6.4 (Snow Leopard) and it's humming along on my more complex version of the script. Someone else will have to test it under 10.7 (Lion) to verify full functionality. Mike, are you up for letting the Lion loos in your Greenhouse again?

Here is the potential fix. The idea is to replace THIS code in the Xytronix Temperature Module AppleScript version 1.2:

--------------------------
tell application "URL Access Scripting"
-- The following web-page request downloads the page and places the html code in a temporary file to be read and parsed.
download ("http://" & LAN_address & "/index." & request_str) ¬
to file temp_file replacing yes
end tell
--------------------------

with THIS code:

--------------------------
-- "URL Access Scripting" disappeared in Apple's OS X 10.7 (Lion)
-- These two lines do the same thing (and also work in OS X 10.6)

set temp_path to POSIX path of temp_file
-- The following web-page request downloads the page and places the html code in a temporary file to be read and parsed.
do shell script "curl -L " & "http://" & LAN_address & "/index." & request_str ¬
& " -o " & temp_path
--------------------------

If I can independently verify that the rest of the script has no problems with Lion, I'll incorporate this into a script update.

-- Chris Galfo


Sat Jul 23, 2011 10:01 am
Profile

Joined: Mar 17, 2010
Posts: 6
Post Re: Xytronix Temperature Module AppleScript
Thanks Chris! You are the man!

Running this on Lion with the posted CURL modifications.

So far so good. Variables being passed to Indigo as expected. :)


Sat Jul 23, 2011 10:33 am
Profile
User avatar

Joined: Nov 18, 2008
Posts: 2253
Location: Berkeley, CA, USA
Post Re: Xytronix Temperature Module AppleScript
Chris Galfo wrote:...I've had it running for the past few hours under Indigo 4 and OS X 10.6.4 (Snow Leopard) and it's humming along on my more complex version of the script. Someone else will have to test it under 10.7 (Lion)...


FYI, I am not sure about the Xytronix script itself, but the change from URL Access Scripting to do shell script...curl should work in any version of AppleScript (well, at least under OS-X).


Sat Jul 23, 2011 11:10 am
Profile
User avatar

Joined: Aug 19, 2007
Posts: 16
Location: Auberry, CA
Post Re: Xytronix Temperature Module AppleScript
Greetings all,

I just posted Version 2.0 of the Xytronix Temperature Module script for Indigo (it should appear in a day or two, after Perceptive Automation looks it over. I when from version 1.2 directly to 2.0 because I needed to change the way it gets data from the Xytronix Temperature Module due to recent changes they have made in their firmware and that entailed rewriting the parsing code. Here's a list of changes and improvements:

- Changes in Version 2.0 :

    Fixed a compatibility issue with Mac OS-X 10.7 (Lion)
    (The version 1.x scripts stopped working when Apple eliminated support for "URL Access Scripting" -- compatibility verified by Mike Brede, thank you!)

    Could no longer use "/index.html" web-page returned by the Xytronix Temperature Module because the latest product revisions now depend heavily on JavaScript code. Switched to requesting the "/state.xml" page. This change means that the temperature alarm states can no longer be read.

    Completely rewrote the parsing code so that it would retrieve data from the "/state.xml" page to pass on to Indigo and added better parsing error messages. (compatibility verified by Richard Calfee, thank you!)

-- Chris Galfo


Tue Aug 09, 2011 10:38 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 8357
Location: Austin, Texas
Post Re: Xytronix Temperature Module AppleScript
Already approved and available. :)

_________________
Jay (Indigo Support)
Image


Tue Aug 09, 2011 11:34 am
Profile WWW
User avatar

Joined: Aug 19, 2007
Posts: 16
Location: Auberry, CA
Post Re: Xytronix Temperature Module AppleScript
Thanks Jay, that was FAST! Lion users and anyone who just purchased one of the new temperature modules will appreciate it! :)


Tue Aug 09, 2011 12:14 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 45 posts ]  Go to page: Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users 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.