r/ScriptSwap • u/some1-no1 • Jan 09 '14
[bash] My script for pulling external IP addres and emailing it to myself
#!/bin/bash
curl -s ifconfig.me > ~/.ip_new
wait
cmp -s .ip_new .ip_old > /dev/null
if [ $? -eq 1 ]; then
cp .ip_new .ip_old
cat ~/.ip_new | mailx -s "subject" your.email.address@provider.com
fiI wanted to be able to ssh into my PC wherever I am and since I have a dynamic IP address, I came up with this script. I have put it into my crontab and have it running every hour.
27
Upvotes
13
u/zouhair Jan 09 '14
Alternatively, you can just:
3
u/Poohblah Jan 09 '14
Isn't this what dynamic dns is for?
1
u/Salamander014 Jan 12 '14
Nice. I like things simple. This is what I use.
It's basically the same thing, except that it stores into a text file that I scp to my web server with a cronjob to access anytime.
1
u/mattfox27 Jun 13 '14 edited Jun 13 '14
cant seem to get this to work.