Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    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

  2. #12
    Linux 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

  3. #13
    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

  4. #14
    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

  5. #15
    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

  6. #16
    Linux 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.

    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.

  7. #17
    Linux Newbie
    Join Date
    May 2005
    Location
    Chennai,TamilNadu, India
    Posts
    141
    I could like some help in configuring sendmail

  8. #18
    Just 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!

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •