Jump to content

Newbee: Trouble with this "easy" script


Recommended Posts

Posted (edited)
test_address="8.8.8.8"                                          
tunnel_interfaceWAN="eth0"                                      
tunnel_interfaceVPN="tun1"                                      
init_ping_tries=2    

ping_tries=init_ping_tries
WANup=0

while  [[ $ping_tries -lt 5] && [ $WANup -eq 0 ]]
do
        if ping -c 1 -W 1 $test_address -I $tunnel_interfaceWAN >/dev/null
  then
                WANup=1
        fi
        ping_tries=$((ping_tries+1))
done

if $WANup -eq 0
  then
        echo "VPN is down because Internet is down [exit 0]"
        exit 0
fi

Im pretty new to bash programming, this script should be simple, but I cant seem to figure out why it is not working correctly.

Is there something wrong with the syntax of my while loop or last if statement?

 

Edited by JackNY

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...