0

Hello,

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!!

************************************************** ***********************************************
#!/bin/bash

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

# the URL that will return your current IP address
CHECKIP='checkip.dyndns.com'

# email details
EMAIL='myemailaddy@myisp.com'
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"

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

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by 6figganigga
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.