View previous topic :: View next topic |
Author |
Message |
carbon Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/gallery/Marvel/Marvel_-_Spiderman.gif)
Joined: 27 Jun 2003 Posts: 455 Location: New York
|
Posted: Tue Aug 05, 2003 1:28 pm Post subject: how to write scripts? |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
kopfarzt Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Simpsons/simpsons_dr_hibbert.gif)
Joined: 05 Apr 2003 Posts: 170 Location: Vienna, Austria
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
kashani Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/9629732313ee51df8c5935.jpg)
Joined: 02 Sep 2002 Posts: 2032 Location: San Francisco
|
Posted: Tue Aug 05, 2003 6:29 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
revertex l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/989373687429a80c3930ca.png)
Joined: 23 Apr 2003 Posts: 806
|
Posted: Thu May 27, 2004 6:22 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
blitzkrieg n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Marvel/movie_x-men_wolverine.gif)
Joined: 22 Apr 2004 Posts: 22 Location: Canada
|
Posted: Thu May 27, 2004 7:35 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
revertex l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/989373687429a80c3930ca.png)
Joined: 23 Apr 2003 Posts: 806
|
Posted: Thu May 27, 2004 8:38 pm Post subject: |
|
|
Thank's blitzkrieg!
Much better than mine! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
sparks Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/16521437040c02c886e15f.gif)
Joined: 05 Mar 2003 Posts: 331 Location: Nashville, TN
|
Posted: Sun Jun 06, 2004 7:44 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Regor Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/18898795783ebdf95b2847c.png)
Joined: 06 Aug 2002 Posts: 545 Location: 39° 2' 48" N, 120° 59' 2" W
|
Posted: Sun Jun 06, 2004 9:22 am Post subject: |
|
|
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". ![Smile :)](images/smiles/icon_smile.gif) _________________ Sometimes the appropriate response to reality is to go insane.
-Philip K. Dick, Valis |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|