Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Results 1 to 2 of 2
  1. #1
    freaky is offline OSXer
    Join Date
    Sep 2003
    Posts
    409
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Applescript that detects if iMac has access to the Internet?

    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
    Mac Pro 2 GHz Quad Xeon, 15 GB RAM, Two 2 TB drives & 60 GB SSD
    MacBook Pro 2.26 GHz Intel Core 2 Duo, 8 GB RAM, 120 GB SSD

  2. #2
    michaelsanford is offline Translator, Web Developer
    Join Date
    Oct 2002
    Location
    Ottawa/Montréal
    Posts
    2,280
    Thanks
    0
    Thanked 5 Times in 5 Posts
    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

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •