#!/bin/bash #Check Your IP and send it to your email account by Macie # Start simple loop while true; do # Use wget to download IP page wget www.whatismyip.com clear # Get IP from downloaded file myip=`cat index.html |grep 'Your ip is' |cut -d's' -f2 |cut -d'W' -f1` rm index.html # Check for prior IP records stored in home dir if [ -f ~/.ip ]; then oldip=`cat ~/.ip` # If IP is same do nothing if [ "$oldip" == "$myip" ]; then echo "IP is same" # If IP is different, record it and email it. else echo "$myip" > ~/.ip echo "The new ip for server is $myip" | mail -s "IP UPDATE FOR SERVER" mail your@email.com fi # If no record of prior ip log found, store it and email it. else echo "$myip" > ~/.ip echo "The new ip for server is $myip" | mail -s "IP UPDATE FOR SERVER" mail your@email.com fi # Repeat script every 15 minutes sleep 900 done