Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > need help with cronned applescript

need help with cronned applescript
Thread Tools
Grizzled Veteran
Join Date: Jan 2001
Location: usa
Status: Offline
Reply With Quote
Nov 7, 2003, 10:04 AM
 
Hi, I wrote an applescript to download a weather map and make it my desktop image. it seems to work fine when I run it standalone.

As a cron job, i get the error that the file can't be found. This error is thrown right after the script downloads the image - I thought that it might be that the script was downloading the picture, the download wasn't finish, and the script kept executing, thus the file wasn't found when the script resizes the picture to fit the desktop.

As a result, I added a delay of 20 seconds (using delay 20 - i hope that is right) after the script downloads, but before I proceed. It still seems very spotty. Again, it works fine when run from script editor or menu, but when run as a cron job.... (osascript /Users/pathto/weather.scpt) Any ideas?

Code:
set myDate to current date set myTime to time of myDate set fileTime to ((myTime div 3600 as string) & "-" & ((myTime div 60) - (myTime div 3600) * 60) as string) --set weather_map to "acttemp_720x486.jpg" -- temperatures set weather_map to "curwx_720x486.jpg" -- surface isobars set the target_URL to "http://maps.weather.com/images/maps/current/" & weather_map set the destination_file to ((path to desktop as string) & "weather-isobars" & "-" & fileTime & ".jpg") tell application "URL Access Scripting" download target_URL to file destination_file replacing yes end tell delay 20 tell application "Image Events" set this_image to open destination_file pad this_image to dimensions {1280, 1024} save this_image with icon close this_image end tell tell application "Finder" set desktop picture to destination_file as alias delete destination_file end tell
     
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
Nov 8, 2003, 07:09 PM
 
might have something to do with cron jobs running as root, so the "path to desktop" might not work. try replacing that with a hard coded path
     
Grizzled Veteran
Join Date: Jan 2001
Location: usa
Status: Offline
Reply With Quote
Nov 9, 2003, 11:16 PM
 
Originally posted by Uncle Skeleton:
might have something to do with cron jobs running as root, so the "path to desktop" might not work. try replacing that with a hard coded path
http://yourethemannowdog.com/

thanks a bunch. I'm just getting into applescript - this was my second project after writing some mail rules that automatically open up URLs in Safari that are contained in those email notifications sent out by Macnn. Applescript rules.
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:23 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2