Wy dosent work? I'm learning bash scripting but this ping operation dosent work i dont know wy, some one can give me a light please?
#!/bin/bash
r1="<UP>!"
r2="<DOWN>!"
if ! ping -c 1 0.0.0.0
then
echo $r1
else
echo $r2
fi
CodePudding user response:
You are using "!" which negates the truth so it returns UP when DOWN and vice versa, try this:
#!/bin/bash
r1="<UP>!"
r2="<DOWN>!"
if ping -c 1 0.0.0.0 ; then
echo $r1
else
echo $r2
fi
~