Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I check whether my internet connection is active on Ubuntu. If I am connected to a wired or wi-fi network, the indicator applet shows that I'm connected. But there is now way to find out the internet is working or not. I have some problem in my internet connectivity and I frequently lose my connection. I found this link is useful

Internet connectivity indicator applet

But I don't know that where should I use this code!

#!/bin/bash

if ping -c 1 -W 2 google.com > /dev/null; then
 echo "Up"
else
 echo "Down"
fi
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The link you indicated is self explanatory. Even so, the necessary parts for implementing the script are:

  1. Open up a console and type:

    mkdir -p ~/scripts && cd ~/scripts

  2. After that type the following

    gedit pingtest.sh

  3. Paste this code:

#!/bin/bash

if ping -c 1 -W 2 google.com > /dev/null; then
 echo "Up"
else
 echo "Down"
fi
  1. Save the file

  2. Again on the console

chmod +x pingtest.sh

Then you have the file created, all you need is to follow the other steps indicated on the link you posted

share|improve this answer
    
Heres some extra info on bash for beginners help.ubuntu.com/community/Beginners/BashScripting –  mark kirby Sep 28 '12 at 9:00
    
Thank you so much!! It worked. –  Sathish Sep 28 '12 at 9:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.