Re: Detecting if connected to internet
Re: Detecting if connected to internet
- Subject: Re: Detecting if connected to internet
- From: Craig Williams <email@hidden>
- Date: Sat, 24 May 2008 13:26:36 -0600
On May 23, 2008, at 10:36 AM, Dan Doughtie wrote:
But sometimes they work off line. I want to add a line that would
check to see if they were on the internet and if so, then send the
backup, else, not.
Any suggested approaches? Ping something and if it fails then assume
youâre offline? Is there an OS status that would indicate this?
Try this.
set providerName to "home.comcast.net" set myResult to do shell script "ping -c 1 " & providerName
if myResult contains "packet loss" then --got a (non-empty) result if myResult contains "100%" then --only consider 100% loss a failure --not connected else --Any other % is a valid connection --Send your backup here end if else --if empty result, the command timed out. end if |
_______________________________________________
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