Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import os, time
  4.  
  5. def getIP():
  6. os.system('dig +short myip.opendns.com @resolver1.opendns.com > raspip.txt')
  7. with open('raspip.txt', 'r') as f:
  8. return f.readline().rstrip('n')
  9.  
  10. def sendIP(currentIP):
  11. os.system('sendEmail ' +
  12. '-o tls=yes ' +
  13. '-f '***@outlook.com' ' +
  14. '-t '***@outlook.com' ' +
  15. '-s 'smtp.live.com' ' +
  16. '-xu '***@outlook.com' ' +
  17. '-xp '**password**' ' +
  18. '-u "raspberry via python" -m ' +
  19. '"' + currentIP + '"')
  20.  
  21. def main():
  22. lastIP = None
  23. while (True):
  24. currentIP = getIP()
  25. if (lastIP != currentIP):
  26. sendIP(currentIP)
  27. lastIP = currentIP
  28. time.sleep(60)
  29.  
  30.  
  31. if __name__ == "__main__":
  32. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement