Re: Why is this AppleScript working unreliably? Any ideas?
Re: Why is this AppleScript working unreliably? Any ideas?
- Subject: Re: Why is this AppleScript working unreliably? Any ideas?
- From: Jeff Gold <email@hidden>
- Date: Mon, 11 Oct 2010 23:55:16 -0400
Hello,
I am using AppleScript for part of the programming on an Animal Rescue website.
I have a database which automatically generates an AppleScript to download JPEG files with animal photos from one of our remote web servers, then sends these images as attachments with an email message.
We use an AppleScript extension called 24U Email OSAX to send the emails. Details about it are here, though I don't think this extension is the problem (it is working reliably in many other areas):
http://www.24usoftware.com/EmailOSAX
I've blocked out actual filenames, paths, emails, ips, etc. below to keep them private. This script works perfectly -- much of the time. Often at other times it fails.
Generally, if it fails, if I run the same *exact* script three times in a row, on the third time it will run correctly. Then subsequent runs will be fine. For a while.
Then at some point the scripts will stop working again. Then, if I run the script once, then a second time, then finally a third time it runs fine again on the third try.
The "3 tries" is consistent once it stops working. It is as if the first two tries something is happening which sets things up so they run on that third try. Odd, never seen anything quite like this. I load the script into AppleScript Editor, hit run. It just stops after the first couple lines. Hit run again, and it downloads the photos but then stops. Hit run a third time, it runs all the way through and sends the email. Then all subsequent times I hit run, it keeps sending them fine. For a while.
I don't get any error messages when it doesn't run. It seems the script starts to run, then just stops in the middle of downloading the files, without continuing or giving an error message. Sometimes if I run the script as a Script Application or in the AppleScript Editor, the editor or application will even just suddenly quit. That is rare, but sometimes that happens. This is with the same exact script, letter for letter, that a few minutes later will work just fine.
Normally I run the script by calling it from another script, but the results are the same whether calling from another script, or if I just load them by hand into AppleScript editor and hit Run.
It is very hard for me to debug something that "usually" works then often won't. I'm certainly no expert, but I'm usually good at writing and debugging scripts. This one has had my working for the last 8 hours, just getting more and more frustrated. Any suggestions on what things I should be checking into to try to resolve this?
FYI... I have AppleScript Editor set to run in 32-bit mode, as 24U Email OSAX requires that. Could it somehow be "getting out of 32 bit mode" from time to time? Don't know how that could happen, I'm just running out of ideas... grasping at straws now!
Hopefully the problem is something simple and obvious to someone on this list, and I am just blind to it from working on this for too long. :-)
Best wishes,
- Jeff Gold
try
set filetoget1 to ("http://www.SOMEDOMAIN.com/VALIDPATH1/VALIDFILENAME1.jpg")
set downloadpath1 to "Macintosh HD:VALIDPATH1:VALIDFILENAME1.jpg"
set filetoget2 to ("http://www.SOMEDOMAIN.com/VALIDPATH2/VALIDFILENAME2.jpg")
set downloadpath2 to "Macintosh HD:VALIDPATH2:VALIDFILENAME2.jpg"
set filetoget3 to ("http://www.SOMEDOMAIN.com/VALIDPATH3/VALIDFILENAME3.jpg")
set downloadpath3 to "Macintosh HD:VALIDPATH3:VALIDFILENAME3.jpg"
tell application "URL Access Scripting"
download filetoget1 to downloadpath1 replacing yes
download filetoget2 to downloadpath2 replacing yes
download filetoget3 to downloadpath3 replacing yes
end tell
set attachment1alias to downloadpath1 as alias
set attachment2alias to downloadpath2 as alias
set attachment3alias to downloadpath3 as alias
set myAttachments to attachment1alias & attachment2alias & attachment3alias
set mySMTP to "00.00.00.00"
set myFrom to "RETURNADDRESSHERE"
set myTo to "email@hidden"
set mySubject to "subject of email to send"
set myBody to "body text of email to send"
send email myBody ¬
subject mySubject ¬
from myFrom ¬
to myTo ¬
via host mySMTP ¬
attaching myAttachments ¬
tell application "Finder"
delete downloadpath1
delete downloadpath2
delete downloadpath3
empty the trash
end tell
end try _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden