On Tue, 11 Jun 2002, Jacques Nilo wrote:

> It says it all. Should work for ethx and pppx IFACEs

Not sure about ethx IFACEs.  I can bring an interface up even if there is
no cable plugged into the NIC... so the value of this test seems minimal
for static ip or dhcp configurations.

> Jacques
> 
> #!/bin/sh
> # Check every IPDELAY seconds that IP exists for IFACE
> # J. Nilo, June 2002
> 
> IFACE=eth2
> IPDELAY=3
> 
> getip() {
>   IP=`ip addr show $IFACE 2>/dev/null | grep inet | \
>         sed 's/.*inet //;s/ .*//;s/\/.*//'`
> }
> 
> echo "Starting checkip: " >> /var/log/syslog

Isn't it better to use 

  logger "Starting checkip"

to keep the logfile line format consistent and avoid stepping on syslogd's
toes?

> while true; do
>         getip
>         if ! [ "$IP" ];then
>                 echo "$IFACE is down"

Probably want to remove the echo command if you do something useful at
this point.

> # Execute any command here
>                 break
>         fi
>         sleep $IPDELAY
> done
> exit

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[EMAIL PROTECTED]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------


_______________________________________________________________

Multimillion Dollar Computer Inventory
Live Webcast Auctions Thru Aug. 2002 - http://www.cowanalexander.com/calendar



------------------------------------------------------------------------
leaf-user mailing list: [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-user
SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html

Reply via email to