Script to check if internet is connected.

I am new at scripting and have a problem.
I need a script to check if my headless server, after starting up in the morning, has an Internet connection or not, and once it has established that it is connected to the Internet it needs to send me a mail that it has a connection.
Now the mail sending part of the script I can do.
However the checking if it has an Internet connection or not is harder and here I get stuck.
I have the following script to check if I have a connection (found it on macinstruct.com).
set intnt to do shell script "ping -c 1 google.com; echo -n"
set paras to number of paragraphs in intnt
if paras < 5 then
Now I would like the script to recheck if it has or has no connection till it has one, and then execute sending the mail. This is where I get stuck.
Anybody have such script or can tell me how to do this?
Thanks.

I am not sure that your method of checking for internet connection is ideal (and I am sure you will get some hints from others). However, what you're looking for is the repeat while ... end repeat loop.
Note that in the example below, I have initialised your variables to an empty string and 1 respectively. You could also just repeat the lines inside the repeat loop.
set intnt to ""
set paras to 1
repeat while paras < 5
set intnt to do shell script "ping -c 1 google.com; echo -n"
set paras to number of paragraphs in intnt
end repeat

Similar Messages

  • NETWORK ERROR.  PLEASE CHECK YOUR INTERNET CONNECTION AND TRY AGAIN

    I've been getting this message when I try and play some
    games...Flash 9.0.115 is required to view this content. Your
    current version is 9.0.47. Please download the latest Flash Player.
    But every time and try and download it I get this error
    message NETWORK ERROR. PLEASE CHECK YOUR INTERNET CONNECTION AND
    TRY AGAIN.
    I've tried changing settings but nothings working, can anyone
    please help me

    I SOLVED IT!!!!! LATEST FLASH IS INSTALLED!!!!
    Here's what I did:
    Read the information in the service note about the ridiculously sensitive download manager (DM)
    ID:
    kb400530
    It gives instructions about internet settings necessary for the DM to work on multiple browsers. I use IE 7. Some were really non-obvious, like windows need to have no constraints on size, position.  Most have to do with security, Active X settings.
    However even after I followed the directions, I got the same error message.
    But I'd gotten the general idea of what the DM needed, and went back to my Internet Options, and made a couple of additional changes. I'm not sure which of these was responsible for the success, but I'm resetting them afterward anyway.
    For all the settings in which they allowed Prompt or Enable, I chose ENABLE.
    I set Enable (vs. Prompt) for Download signed Active X controls (not secure)  - this prompts a security risk bar, which didn't interfere
    I also:
    Set ENABLE for Run components not signed with Authenticode
    Set ENABLE for Allow previously unused ActiveX controls to run without prompt
    Set DISABLE for Automatic prompting for ActiveX controls
    Set DISABLE for Automatice Prompting of ActiveX controls
    Set  DISABLE for Use Pop-Up Blocker
    Set ENABLE for everything in under Scripting section
    Anyway, you get the idea.  I was trying to give the poor software every break I could, and it downloaded with no problem.
    And then, the acid test.....I tried the site that had crashed because of lack of Flash 10 - and it tna perfectly....
    Take that ADOBE!!!!
    I hope something equivalent works for you.

  • Checking for internet connection

    Does anyone know how I can use script to check if the user
    has internet connection?

    I think you'll need to check a server - this can be as simple
    as calling a
    PHP file on your server and if it returns a value you know
    you're connected.
    I don't believe there's another way.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • I am experiencing wireless connection problem on 4s after ios 8.1 upgrade. The wireless icon appears showing that it's connected but webpages do not load. I have checked my internet connection with other devices and seems to be alright. what to do?

    Hi
    I am experiencing wireless connection problem on 4s after ios 8.1 upgrade. The wireless icon appears showing that it's connected but webpages do not load. I have checked my internet connection with other devices and seems to be alright. what to do?
    I have tried reseting the network settings and forgetting my wireless connection and re-connecting to it. I even backed up my phone on itunes and restored it, factory reseted it. Nothing seems to work.
    Also after my upgrade to ios 8.1 my personal hotspot option under cellular data has disappeared.
    Would you please help me out? I would really appreciate it.

    Hi..
    Restart your router then restart the iPhone to test.
    If that doesn't help, try this support article >   iOS: Troubleshooting Wi-Fi networks and connections

  • I am trying to install software for iTwin Connect, but after downloading the dmg file and launching the program, I receive a message saying the file can't open and to check my internet connection.  Any ideas?

    I am trying to install software for iTwin Connect, but after downloading the dmg file and launching the program, I receive a message saying the file can't open and to check my internet connection.  Any ideas?

    Many Thanks, Kurt.
    I knew I'd seen the solution you've provided somewhere - either in MacWorld or MacFormat - but couldn't remember the Gatekeeper bit!
    I shall save it somewhere VERY safe now in case this happens again …
    You have made an old man very happy and saved me from worrying that senile decay had suddenly set in. (I was 70 last week so you might understand the situation from that.)
    Best wishes
    OllyanDinah

  • What is the easiest way to check for internet connection in C#?

    Hi!
    I searched a lot but I didn't get my answer. I'm looking for the easiest way to check for internet connection. Can you help me?
    Thanks a lot.

    Hi Pouya Ebrahimzadeh,
    I suggest you could connect a site to check if it can be opened.
    Public Shared Function CheckForInternetConnection() As Boolean
    Try
    Using client = New WebClient()
    Using stream = client.OpenRead("https://msdn.microsoft.com/")
    Return True
    End Using
    End Using
    Catch
    Return False
    End Try
    End Function
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I get the following message, when trying to check for updates on itunes:-  "The iTunes update server could not be contacted. Please check your internet connection or try again later".

    I get the following message when I go to "check for updates" on iTunes (I have XP on windows). Error message: "The iTunes update server could not be contacted. Please check your internet connection or try again later".
    My firewall (both anti virus firewall and windows firewall, are set up to allow itunes programme to work) - I also have set both internet explorer and chrome to allow
    apple website as an exception.
    However, I still get the same error message... can anyone help?
    Thanks

    Try updating your iTunes using an iTunesSetup.exe (or iTunes64Setup.exe) installer file downloaded from the Apple website:
    http://www.apple.com/itunes/download/

  • Can't log into iMessages and it tells me to go and check my internet connection after checking it and turning it on and off it still doesn't work for iMessage but when I go into safari and other apps it works please help!

    Cant log into iMessage on myI ipad air and get the message " please check your internet connection and try again" and my internet is on and I can connect to it in other applications.

    1. Make sure Date and Time is correctly set; Settings>General>Date and Time>Set Automatically>On
    2. Make sure phone number or email address is correct
    3. Restart iPad
    4. Reset iPad. Hold the Sleep and Home button down (together) until you see the Apple Logo

  • While updating my iphone 4 to 5 I'm getting an error message 'connection is timed out. please check your internet settings' whereas my connection is very much active. Any suggestions!

    While updating my iphone 4 to 5 I'm getting an error message 'connection is timed out. please check your internet settings' whereas my connection is very much active. Any suggestions!

    Check to see if you anti-virus software running, that will at times interfere with the connection with the Apple server.

  • HT1483 I get a message "The Itunes server could not be contacted, check your internet connection" when trying to check for Ipod Nano software updates. I have a 1st generation Nano and haven't updated the software for a while. My internet connection is wor

    I get a message "The Itunes server could not be contacted, check your internet connection" when trying to check for Ipod Nano software updates. I have a 1st generation Nano and haven't updated the software for a while. My internet connection is working. Was thre a change in the internet address for NANO software updates? Do I have to reconfigure something in Itunes to point to the correct address?

    What version of iTunes are you using?  The latest is 10.6.3. In iTunes, choose Help -> About iTunes to check the version number. If it's lower than 10.6.3, download the latest version from here.
    B-rock

  • Why do I keep getting an error message saying that I need to check my internet connection when I try to listen to Radio? I ran diagnostics and my internet connection is fine. I can also access iTunes Store no problem??

    Why do I keep getting an error message "An error occurred while contacting the radio tuning service.Check your internet connection or try again later." This happens when I am trying to listen to Radio (obviously). I ran diagnostics and it said my internet connection was good. I can also connect to the iTunes Store with no problem. Any ideas?

    Hi,
    Maybe the radio connection on the other end is not working. Hope this helps.
    xxmitchxx90

  • How can I get Lightroom help to work in 5.6? I get error that it is unavailable and that I should check my internet connection.

    F1 gives me the following error.
    "Online help for Lightroom is not available.  Please check your internet connection and try again.  Help files can also be installed locally using the Adobe Community Help Tool."
    How can I remedy this?

    This is not a bug, it is intended behavior.
    In search fields you might want to search for parts of the name, using a wildcard, that's why the auto-complete is not working there.
    If an end user wants to search the complete name, he can use the LOV to pick a value.
    Steven Davelaar,
    JHeadstart Team.

  • Using Bridge CS5 exporting to flickr get error message "Unable to connect to Flickr, please check your internet connection and try again."?

    using Bridge CS5 to exporting to flickr, but get error message "Unable to connect to Flickr, please check your internet connection and try again."  please help?

    I'm experiencing the same problem. Don't think I can help, but maybe I can offer an explanation. It looks as if Flickr has changed their API and Adobe will need to update the export plugin to comply to get it working again. I found this announcement on Flickr:
    Flickr: The Help Forum: [Official Thread] Flickr API switching to https-only on June 27th, 2014!

  • My wireless connection is working however when I try to connect to bbc inlayer, it's telling me that I need to check my internet connection. What can I do to fix this?

    My son can't access bbc iplayer to watch current programmes.  The message states to check the internet connection, however we are definitely connected.

    Welcome to the Apple Community.
    Did you follow the instructions in the message and contact Apple, which you can do through iTunes Store Support. If Apple have asked you to contact them, then the issue can only be resolved by them.

  • I had been listen to itunes radio on my computer and now it comes up with the following message"An error occurred while contacting the radio tuning service. Check your internet connection, or try again later???? I have reset cache and it still isn't worki

    I have been listening to iturnes radion on my computer for months. now i get an error.
    "an error occurred while contacting the radio tuning service. Check your internet connection, or try again later".
    I have reset the cache but nothing seems to help. Any help???
    55Annie

    Somebody suggested clearing the Store cache.  I don't know why that would affect the radio.  Seems to have not worked for some, worked for a few or maybe they imagined it.  Many other posts about this if you browse the forum.
    This is happening to some people some of the time in some places, but then not affecting people in other places, or in the same place at different times.  You try to guess what is going on.  Hasn't happened to me.  Maybe it's my iTunes 7.5, or maybe it's luck of the draw since I never use iTunes radio.
    Complain to Apple:
    http://www.apple.com/feedback/itunesapp.html
    Oh, don't expect Apple to say anything about this -- that's not their style.

Maybe you are looking for