JackNY Posted June 27, 2022 Posted June 27, 2022 (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 June 27, 2022 by JackNY
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now