Applescript that detects if iMac has access to the Internet?

freaky

OSXer
I have an applescript I'm using that uploads a file to my site. I'd like to make it so it will only try to upload the file if the computer is online because it currently opens TONS of Script Editor windows if it can't get online. If someone knows how to do the following in Applescript, I'd appreciate it if you coudl let me know how to accomplish this:

Code:
if COMPUTER HAS ACCESS TO THE INTERNET
    DO THIS
end if
 
This example script assumes that:
- You connect via ethernet;
- You can't have an IP address unless you're connected to a WAN;

This is a bit of a hack, there's probably a better way of doing this but I'm running to class...modify as needed.

inet_value contains stuff like ip6 and ip address, so if the string contains any data you have an IP address, otherwise it's blank.

Code:
try
	set inet_value to do shell script "/sbin/ifconfig en0 | grep inet"
end try

if the length of inet_value is not less than 1 then display dialog inet_value
 
Back
Top