Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > Creating a script to notify me of an IP address change

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 12-07-2005   #11 (permalink)
Just 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
storskogen is offline  


Reply With Quote
Old 12-08-2005   #12 (permalink)
Linux Newbie
 
Join Date: May 2005
Location: Chennai,TamilNadu, India
Posts: 141
Send a message via MSN to sharonenoch Send a message via Yahoo to sharonenoch
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
sharonenoch is offline   Reply With Quote
Old 12-08-2005   #13 (permalink)
Linux Newbie
 
deek's Avatar
 
Join Date: Mar 2005
Location: Fort Wayne, IN
Posts: 248
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
deek is offline   Reply With Quote
Old 12-08-2005   #14 (permalink)
Just 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
storskogen is offline   Reply With Quote
Old 12-08-2005   #15 (permalink)
Just 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
storskogen is offline   Reply With Quote
Old 12-13-2005   #16 (permalink)
Linux Newbie
 
Join Date: May 2005
Location: Chennai,TamilNadu, India
Posts: 141
Send a message via MSN to sharonenoch Send a message via Yahoo to sharonenoch
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.

Quote:
I have to get my sendmail configured to be able to send it to any non-local user but thats another problem.
This is what I want to know about, if it is to be done using sendmail.

How do i configure sendmail. I tried some methods of trying to configure it but no success.
sharonenoch is offline   Reply With Quote
Old 12-20-2005   #17 (permalink)
Linux Newbie
 
Join Date: May 2005
Location: Chennai,TamilNadu, India
Posts: 141
Send a message via MSN to sharonenoch Send a message via Yahoo to sharonenoch
I could like some help in configuring sendmail
sharonenoch is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 10:25 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2