I want to write a script, that would keep checking if any of the devices in network, that should be online all day long, are really online. I tried to use ping, but
if [ "`ping -c 1 some_ip_here`" ]
then
echo 1
else
echo 0
fi
gives 1
no matter if I enter valid or invalid ip address. How can I check if a specific address (or better any of devices from list of ip addresses) went offline?
nmap
, it allows you to specify IP address ranges. – Waldmanping -c 1 some_ip_here
". refer this link for more info – Sulfatizeping
command and then checks if that is a non-empty string. Since it always prints something, whether it succeeds or fails, it never prints an empty string. To check if a command is successful, don't surround it in backticks, quotes, or brackets. Just writeif cmd; then ... fi
– Cowcatcher