"Brad Doster" <[EMAIL PROTECTED]> writes:

> I call the following script from rc.local using the the syntax '.
> /path/script-name'.  This makes the variables $DYNIPADDR and $GATEWAY
> available in shell sessions.
> 
> #! /bin/bash
> DYNIPADDR=`\
> /sbin/ifconfig | grep "inet addr:" | grep -v "127.0.0.1" | grep -v
> "192.168.0.1" |\
> sed -e 's/:/ /' | awk '{ print $3}'`
> echo Your current Dynamic IP address is:  $DYNIPADDR
> export DYNIPADDR
> 
> GATEWAY=`\
> /sbin/ifconfig | grep "P-t-P:" |\
> sed -e 's/:/ /' -e 's/:/ /' | awk '{ print $5}'`
> echo Your current Gateway is:  $GATEWAY
> export GATEWAY
> 
> However, I need the variables available to crond, which doesn't appear to be
> happening.  Ordinarily, no one is logged into this system -- it simply acts
> as a DSL router.
> 
> How do I export the variables such that crond and bash scripts that it runs
> can see and use them?

The first thing that comes to mind is to put them in crontab right
above any lines that run scripts. 

Or maybe in the scripts that crontab runs

You might want to cut down on the number of programs called and call only one
program. The one true  `awk'.  .. hehe

If your output looks something like this:

eth0      Link encap:Ethernet  HWaddr 00:00:E8:90:99:20  
          inet addr:206.117.4.160  Bcast:206.117.4.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:71908 errors:0 dropped:0 overruns:0 frame:0
          TX packets:61082 errors:0 dropped:0 overruns:0 carrier:0
          collisions:29 txqueuelen:100 
          Interrupt:9 Base address:0xdc00 

Only with ppp0 or whatever in place of eth0 then this will do the
first job:

 DYNIPADDR=`\
/sbin/ifconfig|awk '/^eth0/ {a=1}\
/UP BROAD/ {a = 0}\
a==1 && /inet addr/{sub(/addr:/,"",$2);print $2}'`

Replacing ^eth0 with ^ppp0 should work for a ppp0 interface. 

I think putting that variable assignment at the top of crontab will do
what you want.

Probably something similar possible for the P-t-P but I don't have
that output.









_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to