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

Re: bash script fails in squeeze



"Bonno Bloksma" <b.bloksma@tio.nl> writes:

[...snip...]
>ping3.sh ----------
>default gateway
>status=0
>ping4.sh ----------
>status=1

[...snip...]

>ping3.sh ----------
># test of $PINGHOST pingt
># pingt hij niet, test dan nog een keer
># pingt hij dan nog niet, verwijder dan de defaultroute
>[ `pingtest $PINGHOST` == NOK ] && \
>[ `pingtest $PINGHOST2` == NOK ] && \
>  sleep 2 && \
>  [ `pingtest $PINGHOST` == NOK ] && \
>  [ `pingtest $PINGHOST2` == NOK ] && \
>   echo no default gateway || echo default gateway

>ping4.sh ----------
># test of $PINGHOST pingt
># pingt hij niet, test dan nog een keer
># pingt hij dan nog niet, verwijder dan de defaultroute
>[ `pingtest $PINGHOST` == NOK ] && \
>[ `pingtest $PINGHOST2` == NOK ] && \
>  sleep 2 && \
>  [ `pingtest $PINGHOST` == NOK ] && \
>  [ `pingtest $PINGHOST2` == NOK ] && \
>  nodefaultgw

[...snip...]

>I hope someone can find a reason why for instance ping4 fails and ping3 does not.

ping3 does not fail because you have '|| echo default gateway' on the
end, and this is the branch that is being taken. echo(1) returns true so
you get a status of zero from the whole list.

ping4 does not have an '|| cmd' branch, so the whole list retuns false
(non-zero).

These results are consistent with one of the pingtest commands returning
OK (or not returning NOK, technically)

I think you are looking in the wrong place.



Reply to: