- #get the current ip
- curl curlmyip.com > new_ip.txt
- #compare the current ip with the former ip
- find new_ip.txt
- find old_ip.txt
- result=$(diff -y -W 72 new_ip.txt old_ip.txt)
- #If it hasnt changed
- if [ $? -eq 0 ]
- then
- echo "no change"
- #if it has changed
- else
- echo "ip updated , sending email"
- FROM="Biko@knightwise.com"
- TO="feedback@knightwise.com"
- SUBJECT=`date`
- #send out new ip
- sendemail -f "$FROM" -t "$TO" -u "Ip update for $SUBJECT" -m `cat new_ip.txt` -s out.telenet.be
- #log new ip as current ip
- mv -f new_ip.txt old_ip.txt
- fi
SHARE
TWEET
Untitled
a guest
Jan 9th, 2015
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
