daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jan 9th, 2015 161 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #get the current ip
  2. curl curlmyip.com > new_ip.txt
  3.  
  4. #compare the  current ip with the former ip
  5. find new_ip.txt
  6. find old_ip.txt
  7. result=$(diff -y -W 72 new_ip.txt old_ip.txt)
  8.  
  9. #If it hasnt changed
  10. if [ $? -eq 0 ]
  11. then
  12. echo "no change"
  13.  
  14. #if it has changed
  15. else
  16. echo  "ip updated , sending email"
  17. FROM="Biko@knightwise.com"
  18. TO="feedback@knightwise.com"
  19. SUBJECT=`date`
  20.  
  21. #send out new ip
  22. sendemail -f "$FROM" -t "$TO" -u "Ip update for $SUBJECT" -m `cat new_ip.txt` -s out.telenet.be
  23.  
  24. #log new ip as current ip
  25. mv -f new_ip.txt old_ip.txt
  26. fi
RAW Paste Data
Top