danielhilst

Send ip to my mail

Jun 18th, 2012
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.36 KB | None | 0 0
  1. #!/bin/bash
  2. # mutt should be configured
  3. # to send email using mstmp and gmail
  4.  
  5. myip_file=/tmp/myip.txt
  6.  
  7. getip()
  8. {
  9.     curl ifconfig.me/ip
  10. }
  11.  
  12. mailme()
  13. {
  14.     echo "$*" | mutt -s "Desk ip" danielhilst@gmail.com
  15. }
  16.  
  17. ##
  18.  
  19. oldip=$(cat $myip_file)
  20. newip=$(getip)
  21.  
  22. if test "$oldip" != "$newip"; then
  23.     echo $newip > $myip_file
  24.     mailme $newip
  25. fi
Advertisement
Add Comment
Please, Sign In to add comment