Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
how to write scripts?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
carbon
Guru
Guru


Joined: 27 Jun 2003
Posts: 455
Location: New York

PostPosted: Tue Aug 05, 2003 1:28 pm    Post subject: how to write scripts? Reply with quote

i want to write a script that will send me a email to tell me my dynamic ip has changed or even go to a website and update it.
_________________
I do what I want, and that's what I do.
GNU World Domination

Carbon
Back to top
View user's profile Send private message
kopfarzt
Apprentice
Apprentice


Joined: 05 Apr 2003
Posts: 170
Location: Vienna, Austria

PostPosted: Tue Aug 05, 2003 4:38 pm    Post subject: Reply with quote

Take a look at http://www.dyndns.org, especially their Client Section.

kopfarzt
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Tue Aug 05, 2003 6:29 pm    Post subject: Reply with quote

emerge dyndnsupdate

emerge -s is your friend.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
revertex
l33t
l33t


Joined: 23 Apr 2003
Posts: 806

PostPosted: Thu May 27, 2004 6:22 pm    Post subject: Reply with quote

I like this one, it's not mine, i just did some changes to suit my needs.
Code:

wget -O - -q http://www.whatismyip.com | grep h1 | cut -f 4 -d " " | mail yourmailaddress@domain

need mailx to send mail, but you may use mutt instead.
just put in your cronjob.
you don't need to register in any service to use it, i find it useful for people like me that don't host services like web servers but need to know your ip for things like ssh.
Back to top
View user's profile Send private message
blitzkrieg
n00b
n00b


Joined: 22 Apr 2004
Posts: 22
Location: Canada

PostPosted: Thu May 27, 2004 7:35 pm    Post subject: Reply with quote

Code:

#!/bin/bash
OLDIP=`cat ~/.ip`
NEWIP=`wget -O - -q http://www.whatismyip.com | grep h1 | cut -f 4 -d " "`

if [ "$OLDIP" != "$NEWIP" ] ; then
        echo "$NEWIP" > ~/.ip
        echo "$NEWIP" | mail frank@frank-networks.com -s "IP has changed to $NEWIP"
fi


install into your crontab to run as often as you like: it will only mail you when the ip address changes.
Back to top
View user's profile Send private message
revertex
l33t
l33t


Joined: 23 Apr 2003
Posts: 806

PostPosted: Thu May 27, 2004 8:38 pm    Post subject: Reply with quote

Thank's blitzkrieg!
Much better than mine!
Back to top
View user's profile Send private message
sparks
Guru
Guru


Joined: 05 Mar 2003
Posts: 331
Location: Nashville, TN

PostPosted: Sun Jun 06, 2004 7:44 am    Post subject: Reply with quote

blitzkrieg wrote:
Code:

#!/bin/bash
OLDIP=`cat ~/.ip`
NEWIP=`wget -O - -q http://www.whatismyip.com | grep h1 | cut -f 4 -d " "`

if [ "$OLDIP" != "$NEWIP" ] ; then
        echo "$NEWIP" > ~/.ip
        echo "$NEWIP" | mail frank@frank-networks.com -s "IP has changed to $NEWIP"
fi


install into your crontab to run as often as you like: it will only mail you when the ip address changes.


Thats a great script but when I run it, i receive this error.
Code:
/home/ben/.scripts/ip-change: line 7: mail: command not found


Now, I have postfix installed and setup correctly. How can I use it to send this e-mail. Thanks
_________________
True trade is honest, but not merciful. Politics is dishonest, no matter how merciful... and war is neither honest nor merciful.... therefore, choose trade above politics, but politics above war.
Back to top
View user's profile Send private message
Regor
Guru
Guru


Joined: 06 Aug 2002
Posts: 545
Location: 39° 2' 48" N, 120° 59' 2" W

PostPosted: Sun Jun 06, 2004 9:22 am    Post subject: Reply with quote

sparks wrote:

Thats a great script but when I run it, i receive this error.
Code:
/home/ben/.scripts/ip-change: line 7: mail: command not found


Now, I have postfix installed and setup correctly. How can I use it to send this e-mail. Thanks


You don't. Not directly anyway. Internet email is split into 3 different functions: transport, delivery, and user interface. It is nearly always the case that 2 completely different programs are required in order to fullfil all of these functions and it's fairly common that 3 or more will come into play.

Postfix is primarily a Mail Transport Agent (MTA), (it can also serve as an MDA) and is not suitable for use directly by a user. What you need is a MUA, which is exactly what the "mail" program the script calls is. Other common MUAs include mutt, elm, pine, sylpheed, thunderbird, evolution, kmail, etc.

Ok, now that the lecture is over the short answer is "emerge mail-client/mailx". :)
_________________
Sometimes the appropriate response to reality is to go insane.
-Philip K. Dick, Valis
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum