PDA

View Full Version : some issues with a reoccuring event




mufflon
Jul 19, 2007, 05:07 PM
I must confess I'm not the most well versed when it comes to reoccuring events, especially those that i don't have to attend to every waking hour :)
I have made a small imap php script to gather news to a site I'm developing on my spare time, but I don't know what to do :confused:

Ideally the script should do:
1) open any kind of browser
2) go to site
3) close browser

every one hour

the hardware I'm using is 10.4 server edition, though i'm not sure it matters

I have sought high and low with rather crappy results, I might have looked in the wrong locations, but definetly not found anything.



HiRez
Jul 19, 2007, 11:07 PM
Ideally the script should do:
1) open any kind of browser
2) go to site
3) close browserIf it's something that just needs to run on your own machine, it sounds like a perfect job for AppleScript (although maybe I don't understand everything you're trying to do). You could also set up a cron event to fire it off every hour, or just have it run in the background continuously and activate once per hour.

mufflon
Jul 20, 2007, 01:49 AM
Sigh and here I was trying to teach myself cron from random sites while applescript beckoned with simplicity. Tnx for the help though :)

The script I made:


repeat with shotcount from 1 to 1000
tell application "Safari"
activate
set the URL of document 1 to "myURL"
end tell
delay (60 * 60 * 3)
end repeat

I reckon I can accept restarting the script once every 3000th hour or so =)

semaja2
Jul 20, 2007, 01:53 AM
why not curl or wget the page? or do you actually want to see the page?

curl http://google.com > /dev/null

HiRez
Jul 20, 2007, 02:17 AM
I reckon I can accept restarting the script once every 3000th hour or so =)Just make it an endless loop and put it in System Preferences > Accounts > Login Items and you won't ever have to touch it. I think there's a way to make AppleScripts run without showing up in the dock or command-tab view but I don't know how.

MongoTheGeek
Jul 20, 2007, 06:55 AM
Sigh and here I was trying to teach myself cron from random sites while applescript beckoned with simplicity. Tnx for the help though :)

The script I made:


repeat with shotcount from 1 to 1000
tell application "Safari"
activate
set the URL of document 1 to "myURL"
end tell
delay (60 * 60 * 3)
end repeat

I reckon I can accept restarting the script once every 3000th hour or so =)

Try this. It will bog the system far less


on idle
tell application "Safari"
activate
set the URL of document 1 to "myURL"
end tell
return 3*hours
end idle


save it as a stay up application.

if you really feel the need to use repeat and delay


repeat
tell application "Safari"
activate
set the URL of document 1 to "myURL"
end tell
delay (60 * 60 * 3)--this works but 3*hours is easier to read
end repeat