If you are looking to determine the state of a host before actioning something on it then the code snippet below is perfect.
((count = 60))
while [[ $count -ne 0 ]] ; do
ping -c 127.0.0.1
rc=$?
if [[ $rc -eq 0 ]] ; then
((count = 1))
else
sleep 1
fi
((count = count - 1))
done
if [[ $rc -eq 0 ]] ; then
echo "The target host is now back online"
#ANY OTHER ACTIONS IF SUCCESSFUL
else
echo "The target host failed to respond to ping requests after maximum attempts exceeded."
#ANY OTHER ACTIONS IF FAILED
fi