Script to Keep Internet Connection "Active"?

Hello!

Is there a ‘Script’ that would fool “Internet Connect” into thinking the connection is ACTIVE so one could start a large download and go to bed or leave the computer and come back to a completed download?

I have dial-up (no DSL available) and I’ve changed ISPs 3 times this week just to get a 55.7MB driver download for my HP Printer in preparation for Tiger (I’m going to ‘Erase and Install’ this upgrade cuz I want to start FRESH), but they all disconnect if I don’t keep opening web pages or check my ‘Mail’. Today I finally got my download, after 4 days of frustration, by sitting at my iMac and switching web pages every 8 minutes. It took 4-1/2 hours! I can’t imagine what I’ll need to do when Apple posts the Tiger 10.4.1 update, which is already mentioned on their web page. (Actually, I suppose it will be the 10.4.2 COMBO that will be my nemesis.) :shock:

I had a lot of time to think “There must be a better way!” and that’s when I thought about AppleScript. I know ZIP about AppleScript but I can’t be the only one with this download problem. Yes, I’ve unchecked the box “Disconnect if Idle for XX Minutes” in Internet Connect, and my iMac is set to never sleep, etc. I’ve even got ‘Mail’ set to “Check Every 5 Minutes”, but none of that helps. I thought that maybe there could be a script that would just go thru my Safari BookMarks and open a new one every 7 minutes. Does that sound like something that would work?

Thank you for your time in reading about my ‘woes’.

Judie

You could write an “on idle” script, but if just moving the mouse periodically is sufficient, the best way I know of is to useStick Software’s “Jiggler”. I use it to prevent sleep, but it simulates moving the mouse every few minutes, so it might prevent a hangup. No script to write.

If moving the mouse every few moments isn’t sufficient then an on idle script is required. They go like this:

on idle
	do_something()
	return (integer) -- The integer is in seconds, so something like 300 say
end idle

on do_something()
tell application Safari
open location "http://www.google.com/"
delay 20
close window 1
end tell
end do_something

I haven’t tested this and you’ll have to go to the Activity Monitor (in Utilities), to stop it.

Thank you, NovaScotian, but, according to my ISP Tech Support, the only thing that Internet Connect considers ACTIVE is changing web pages and checking for Mail. They said, “reading and typing” is not considered an “activity”.

I have Mail set to check every 5 minutes, but that isn’t working either.

Does anyone know of a web page that auto-refreshes every 15 minutes or LESS? Wouldn’t that work?

Thanks again!

Looks like the ISP TS doesn’t have a clue or that you must actually receive some mail or send some to be considered active - just checking isn’t enough activity, and clearly the ongoing download you are trying to rescue isn’t “active” enough either or you woiuldn’t need this fix.

That was the purpose of the “on idle” script, but be more specific about what you know for certain works - clearly the ISP techie isn’t much help. Some testing is required. One possibility is just that your telephone connection is so bad (noisy) that the modem is dropping out. The other is that your ISP has some strange rules.

Can you, for example, find something on VersionTracker that is big enough to time out reliably, but not much bigger than that, and then see if sending yourself an email, checking for it 5 minutes later, sending it again, receiving it again, etc. works. Alternatively, can you just open a web page, close it right after the page is complete, wait 5 minutes and open it again (same address) to keep the connection? Pick something where the content changes every time or you’ll just be looking at your own browser cache. Another option is to go to something like: the world time server and refreshing the page every few minutes. What works?

I’m pretty sure internet connect merely monitors the connection, and doesn’t care what you’re sending or recieving… as long as it’s an active request to the internet. You shouldn’t need to do anything but request a web page to get the connection to stay open. Note that your isp may be caching dns requests, so you may need to send unique http requests to make them think you’re loading different pages… so you could query a search engine and use a random query to make it look like you’re on a web searching frenzy. I do this manually all the time when I’m visiting an unfortunate family member who has a dial-up connection, to keep the connection open. And, as NovaScotian suggests, the only time’s I get booted are when the phone line connection sucks or the isp’s server malfunctions. If you simply request a trivial web page in the background every few minutes, that should make the connection think you’re doing something really important, and keep it from timing out.

My first suggestion would be to use curl and a shell script. The request is sent as if you’re using a browser, but it doesn’t require that any browser be open. The following script will search for a new random string at yahoo.com for whatever interval you set in the ‘requestInterval’ property. Since it’s applescript, and not your usual download client, you’ll never know it’s running. Just make sure you remember to turn it off, or add some code to beep or dialog to periodically remind you that it’s on. :slight_smile:

property requestInterval : 5 --> Number of minutes between queries
property requestURL : "http://search.yahoo.com/search?p="

on idle
	set tmpQuery to random number from 10000 to 99999
	set flag_A to "-A 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/175 (KHTML, like Gecko) Safari/1.3' "

	(* Using curl *)
	set tmpScript to ("curl " & flag_A & requestURL & tmpQuery) as string
	do shell script tmpScript

	return (requestInterval * 60)
end idle

Depending on your system and what types of requests your isp considers legitimate enough to keep the connection active, you could alternately use ping to simply send a ping request to a remote server. Ping essentially justs sends a message to the requestURL and asks it if it’s alive or not. You could use any domain or ip address that you know is valid (and allows pinging). The script may hang for a while if the address is invalid, so try to pick something you know is solid. Ping may not meet the uniqueness criteria of the isp, though.

property requestInterval : 5 --> Number of minutes between queries
property requestURL : "[url=http://www.google.com]www.google.com[/url]"

on idle
	set tmpScript to ("ping -c 1 " & requestURL) as string
	do shell script tmpScript

	return (requestInterval * 60)
end idle

Both of the scripts above should be saved as “application”, and you should check the “stay open” button when saving. I’m on cable and don’t have any way to test these, so let me know if either works as intended.

You could also use the recommendation posted by NovaScotian above, which will open a web page in whatever the default browser is. As I noted though, you may need to somehow randomize your requests, as repeated calls to the same url (like www.google.com or checking your mail) may match existing dns requests on your isp’s cache and not be considered unique requests.

One final recommendation I have is to get a cable modem, and never worry about timing out. :wink:

Good luck…
j

Thank you both, NovaScotian (we were in Nova Scotia during Hurricane Hortense in 1996 or 1997 and we never wanted to leave!) and jobu (we moved to Oregon 3 years ago after a lifetime in Phoenix !).

I posted my troubles on the Apple Applescript forum as well as here and a wonderful guy wrote a script and posted it to his web page for me to download and drop in a folder in my AppleScript folder and it works perfectly. I don’t know what the script says, all I know is that he had me drag the script icon into my dock to use when I will be away from my iMac. What it does is every 8 minutes it refreshes the “Google News” page and it keeps my connection active forever. (I let it run all night last night and it was still going this morning, so my problem is solved.)

I find this stuff interesting, but above my Mac-head, so I’m going to buy the “AppleScript for Dummies” book and get my ‘feet wet’. Maybe someday I will understand the posts I read here at your forum.

Thank you again for your time and replies. :smiley: