Presumably all you need is some internet activity to stay online. If pinging an external address is enough and you know how to write an “on idle” handler set to return every 23 hours or so, this line will do:
set intnt to do shell script "ping -c 1 63.208.196.110"
If a ping isn’t enough, then getting a web page in your idle handler might be better:
set theHTML to my get_url("checkip.dyndns.org")
on get_url(this_url)
set browser_string to "'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/125.4 (KHTML, like Gecko) Safari/125.9'"
return do shell script "curl " & (quoted form of this_url) & " -A " & browser_string
end get_url
Hi, August. I don’t think “connect” is an applescript command - you have to do something that requires the internet so the system will connect. Also, idle handlers don’t have names - there can be only one in a script. If you want a label in the form of a comment use two dashes: – Internet Connect.
Finally, AppleScripts normally quit when their work is complete. To make them stay open you have to save them as Stay Open applications (options under save as…) and you’ll have to quit them from another script or from the Activity Monitor.
on idle
set theHTML to my get_url("checkip.dyndns.org")
return 3600 -- this is in seconds. Once an hour should be fine.
end idle
on get_url(this_url)
set browser_string to "'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/125.4 (KHTML, like Gecko) Safari/125.9'"
return do shell script "curl " & (quoted form of this_url) & " -A " & browser_string
end get_url
In my system (Panther 10.3.9) Internet Connect doesn’t have a dictionary (in fact trying to open its dictionary crashes my Script Editor), but that doesn’t mean IC won’t respond to the command. I don’t know why your idle handler won’t work when the straight-up script (which doesn’t need the return 10) does.
I don’t have a DSL connection so I can’t try any of these (I’ve got a 10 Mbit/sec cable connection that’s online 24/7).
It’s possible that it crashes because “Internet Connect” is already connected. I played quite a while with that app a year ago and in the end all I used was something like:
on run
tell application "Internet Connect" to connect -- or not... if you'll run the script while already connected
end run
on reopen
display dialog "Quit?" buttons {"No", "Yes"} default button 1 with icon stop giving up after 5
if button returned of the result is "Yes" then tell me to quit
end reopen
on idle
try
tell application "Internet Connect"
if state of status of current configuration is not equal to 8 then connect -- that is, if not connected.... connect! Found out trying and logging a lot...
end tell
-- close window 1 -- if you want to get it out of the way...
-- tell application "System Events" to set visible of process "Internet Connect" to false
end try
return 3600
end idle
on quit
ignoring application responses
tell application "Internet Connect" to quit -- or not... your choice.
end ignoring
continue quit
end quit
“connect” is an applescript command when inside a tell app “Internet Connect” block. Of course, you’d have to save your script as a stay open for any of the above handlers to work (excepting ‘on run’). I didn’t test it exactly as is, but it should work… Hope it helps.
I have been working on a similar problem. I found some code that I have since adapted to automatically connect my VPN whenever an active network connection is detected.
My problem is that if Internet Connect is not set to the VPN screen, then the connect command makes it try to dial the modem or connect to an AirPort or some other unwanted activity.
How can I tell Internet Connect to change to the VPN mode, or simply tell it to connect that.
I also seem to be unable to tell it what configuration to use.
I haven’t got any VPN network so I didn’t know which one you needed… but this worked… at least “Internet Connect” threw a “server not found” error.
tell app "Internet Connect" to connect configuration (get name of PPTP Configuration 1) -- or <L2PT Configuration> or whatever you have... check the dictionary!
It seems that Internet Connect connects by configuration name, not class. I created an empty PPTP configuration and it worked, apart from the error that no connection could be made since I had no current connection to the internet. If you have more than one just specify it’s name and it should work.