Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Queries http://checkip.dyndns.com/
- #Displays current ip assigned by ISP
- #Appends text file in home directory
- #Includes time/date stamp
- clear
- echo "getIP is attempting to get ip..."
- curl -s http://checkip.dyndns.com/ > /home/$USER/.checkIp
- sed -n '/<body>Current IP Address:/,/<\/body>/p' /home/$USER/.checkIp | sed -e '1s/.*<body>Current IP Address://' -e '$s/<\/body>.*//' >> /home/$USER/.ip
- if [ -s /home/$USER/.ip ] ; then
- clear
- echo "Success!"
- ipAd=$(</home/$USER/.ip)
- dateStmp=$(date +%D)
- timeStmp=$(date +%r)
- echo -e "$ipAd - $timeStmp $dateStmp" >> /home/$USER/ISP-ips
- echo -e "Current IP assigned by ISP:$ipAd\n"
- else
- clear
- echo -e "No response from CheckIP, try again...\n"
- fi
- rm /home/$USER/.checkIp
- rm /home/$USER/.ip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement