Guest User

Untitled

a guest
Oct 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  2. * * * * * /home/jj/Desktop/IP/publicIP.sh
  3.  
  4. #!/bin/bash
  5.  
  6. #Give crontab a path to follow according to what i have read ?????
  7. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/jj/Desktop/IP/
  8.  
  9.  
  10. #Get last saved IP address
  11. ip1=$( cat /home/jj/Desktop/IP/ip.address.txt )
  12.  
  13. #This is the command to see public IP address
  14. dig +short myip.opendns.com @resolver1.opendns.com > ip.address.txt
  15.  
  16. #This is the updated IP adress currently in use
  17. ip2=$( cat /home/jj/Desktop/IP/ip.address.txt )
  18.  
  19. #Check to see if it is the same IP
  20. if [ $ip1 != $ip2 ]; then
  21.  
  22. #If the IP is different, the IP has changed. Notify me via email
  23. cat /home/jj/Desktop/IP/ip.address.txt | mail -s "IP Address" user@gmail.com
  24.  
  25. #EOF
  26. fi
  27.  
  28. > ip.address.txt
  29.  
  30. > /home/jj/Desktop/IP/ip.address.txt
Add Comment
Please, Sign In to add comment