Results 11 to 18 of 18
If got this from a nice person at the LTSP IRC forum. Not tried it yet but going to
#!/bin/sh
EMAIL=$1
FILE=/var/run/ipwatch
DEV=eth1
NEWIP=`ifconfig $DEV | awk '/inet addr/ {print ...
- 12-07-2005 #11Just Joined!
- Join Date
- Dec 2005
- Posts
- 3
If got this from a nice person at the LTSP IRC forum. Not tried it yet but going to
#!/bin/sh
EMAIL=$1
FILE=/var/run/ipwatch
DEV=eth1
NEWIP=`ifconfig $DEV | awk '/inet addr/ {print $2}' | cut -d: -f2`
[ -e $FILE ] && OLDIP=`cat $FILE`
if [ "$NEWIP" != "$OLDIP" ]; then
echo "New IP: $NEWIP" | mail -s "IP Changed" $EMAIL
echo $NEWIP > $FILE
echo "Notified by email ($EMAIL)"
fi
- 12-08-2005 #12Linux Newbie
- Join Date
- May 2005
- Location
- Chennai,TamilNadu, India
- Posts
- 141
hi storskogen
What all are the settings should be done before executing the command
echo "New IP: $NEWIP" | mail -s "IP Changed" $EMAIL
Since i just tried the command here manually with the relevant data but no mail has come to my account.
Are there any steps to set up before sending mail. if yes then could you list out the steps?
Sharon
- 12-08-2005 #13
Maybe I am missing something, but an email should only be sent if your IP address changed. If your IP didn't change, and you didn't get an email, it is working as designed.
Join the Open Source Revolution. Support GNU/Linux.
Find me at: www.deeksworld.com
Registered GNU/Linux User #395777
- 12-08-2005 #14Just Joined!
- Join Date
- Dec 2005
- Posts
- 3
EMAIL=$1 should be changed to EMAIL=yourmail@dot.com
first time you run the script:
sh ./ipnotify (if you name the file that)
it creates /var/run/ipwatch with your ip. change it to test the script and run it again.
I have to get my sendmail configured to be able to send it to any non-local user but thats another problem.
I put the script as cron job and running every hour
- 12-08-2005 #15Just Joined!
- Join Date
- Dec 2005
- Posts
- 3
and deek is right, it only send you an email if the ip has changed.
change the dev variable if you have any other than eth1 as your WAN eth
- 12-13-2005 #16Linux Newbie
- Join Date
- May 2005
- Location
- Chennai,TamilNadu, India
- Posts
- 141
For me the problem is that I just want to send a simple mail
saying hello or something like that to a non local user eg sharon@yahoo.com.
This is what I want to know about, if it is to be done using sendmail.I have to get my sendmail configured to be able to send it to any non-local user but thats another problem.
How do i configure sendmail. I tried some methods of trying to configure it but no success.
- 12-20-2005 #17Linux Newbie
- Join Date
- May 2005
- Location
- Chennai,TamilNadu, India
- Posts
- 141
I could like some help in configuring sendmail
- 10-19-2011 #18Just Joined!
- Join Date
- Oct 2011
- Posts
- 2
Hello
I needed the exact same thing and I used this thread as a guide
What I did was the following
#!/bin/bash
CURRENT=`curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<$
#The curl command prints my public ip, since i am behind a router
DIR=/script/dir/currentip
OLD=`cat $DIR`
if [ "$CURRENT" != "$OLD" ]; then
echo $CURRENT>$DIR
cat $DIR | mail -s "your IP" your.mail@provider.com
fi
Then I scheduled it using crontab -e and inserting the following line to make it run every 45 minutes.
*/45 * * * * /script/dir/script.sh
Hope this helps somebody!



