Sorry UNIX newbie. I have a script that runs on my NAS that simply checks to see what my IP is and runs a script to reconnect a VPN is it's changed.
NOTE: I've changed the first four number in IP below to 'x' for this example I know they need to reflect my real IP address.
#!/bin/sh
YOUR_IP="$(w3m -dump http://checkip.dyndns.org)"
echo "Current ip:" "$YOUR_IP"
if [ "$YOUR_IP" == "Current IP Address: XX.XX.148.73" ]
then
echo "UP VPN is active :)"
else
echo "DOWN VPN is disconnect :("
sh /opt/etc/init.d/S20openvpn restart
fi
echo "$(date +"%d / %m / %Y")"
echo "$(date +"%H : %M : %S")"
echo "------------------------"
exit
Can anyone tell me why the if else statment does not run. In my logs I get the below. I guess the statement must error or it would echo something, and at the moment it doesn't. It might just be a syntax error, or maybe w3m -dump doesn't get it results before the if else is run put I don't know enough UNIX to debug. Any help would be amazing.
Current ip: Current IP Address: XX.XX.148.73
16 / 05 / 2012
18 : 50 : 01