I'm fairly new to Linux and have managed to make this script below work. Basically it gets my current external ip and emails it to me. It works great as a cron job daily but I was wondering if some of you guru's may be able to augment this script to ONLY email me when the external IP changes...(maybe put the current one in a variable then compare it to one in a file if they are the same do nothing if not email me the new and update the one in the file) I dunno some logic like that....anyone willing to take on this task because i"m stumped!!

************************************************** ***********************************************

# cmd variables
SED=`which sed`
CURL=`which curl`

# the URL that will return your current IP address

# email details
SUBJ='Current IP Address'

# get the current IP address
IP1=`$CURL -# $CHECKIP | sed -nr 's,^.*: ,,;s,<.*$,,p'`

# email the current IP address
echo "Your current IP address is $IP1." | mail -s "$SUBJ" "$EMAIL"

************************************************** ***********************************************

you can save your IP in a file. check for file existence and if exists, read it and save the IP contained in the file into variable. then check your IP, comparing it with the variable. If not the same, email

Great...and since I know little on shell script can you just code that logic for me into my script above?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.