hi,
how about this...

#!/bin/bash
GW1 = 'ping -c2 xxx.xxx.xxx.xx1 | grep "packet" | cut -d"," -f3 | cut -d"
" -f2 ' 2>/dev/null
GW1 = 'ping -c2 xxx.xxx.xxx.xx2 | grep "packet" | cut -d"," -f3 | cut -d"
" -f2 ' 2>/dev/null

if [ "$GW1 = "0%" ] && [ $GW2 = "0%" ]; then
    ip route flush blah. .. blah...
    echo -en "All connections are OK, Resuming normal operation"
elif [ "$GW1 !="0%" ] && [ $GW2 = "0%" ]; then
    ip route flush..... bleeeh, ,.......,
    echo -en "GATEWAY 1 is down... Switching all route to GATEWAY 2!!!"
elif [ "$GW1 ="0%" ] && [ $GW2 != "0%" ]; then
    ip route flush..... bloooh, ,.......,
    echo -en "GATEWAY 2 is down... Switching all route to GATEWAY 1!!!"
else
   echo -en "patay ang dalawang gateway or baka high latency lang, oopps"
fi
#----------end script

correct me if I am wrong, but this is how I analyzed your problem..

cheers...

ian perez


 >
> > > i have created a script that checks other servers and depending on
whether
> > > they are up, it would change the default gw.  anyway, i am planning on
> > > adding this to crond.  when it ran, it said:
> > > /root/scripts/gwchk: [: =: unary operator expected
> > > /root/scripts/gwchk: [: =: unary operator expected
> >
> > > in /etc/rc.d/rc.local, i have set the following GW=gateway1.  in the
> > script,
> > > i have a "if [ $GW = 'gateway1' ]; then"  it seems that the variable i
> > have
> > > set at startup does not seem to get carried "globally."  anyone know
how i
> > > can set a variable up for global use?
> >


_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

Fully Searchable Archives With Friendly Web Interface at http://marc.free.net.ph

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to