[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Please help with redhat script

Chris Dowling <sugarboy sb ii net> writes:

> On Mon, 18 Dec 2000, Johnathan Smith wrote:
> > Please help with redhat script
> > 
> > I am using redhat 7.0 and I would like to find out how
> > to write a script that I could run in cron.
> > 
> > I need the script to get my ip address and then email
> > it to me.
> > 
> > This will have me login to my home computer from work.
> > 
> > please email me at john 1hostplus com if you could help
> > 
> put the following command in /etc/ppp/ip-up.local
> ifconfig ppp0 | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{ print
> $1 } ' | mail -s 'ip address' user domain com

NOTE:  Not absolutely sure this applies to rh7 but.....

If you create the /etc/ppp/ip-up.local script and give it chmod 755
and a shebang like:


That script should automatically be fed a variable that contains your
currently negotiated address.  That variable is `$4'.

So no need to poll ifconfig for it.

It should be available with a simple:

        echo $4

So your script could be as simple as:

cat /etc/ppp/ip-up.local:
  echo $4 |mail -s "Current IP" address where you want it          

The ip-up.local script is supposed to fire only when a successfull
connection has been negotiated by the ppp daemon.  So should contain
the most recent result of those negotiations.

Of course the above relies on you having configed things so that the
`mail' client works. 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]