I'm writing on a script rebooting various Server's. After the reboot I want to "wait" until all Server's are back online. (To keep things simple I defined for me online=pingable)
So for each Server I do
ServerXY_W=1 echo -n "waiting for ServerXY ..." while (($ServerXY_W == 1)) do if ping -c 1 -w 0.2 192.168.123.123 &> /dev/null then echo "ServerXY is back online!" ServerXY_W=0 else echo -n "." fi done
What I would expect (and like) would be an output like e.g.
waiting for ServerXY ................. ServerXY is back online!
where the dots .... would appear one by one.
But what actually happens is first there is only
waiting for ServerXY ...
for a while and when the Server is back I get the last dot and the last line like
waiting for ServerXY .... ServerXY is back online!
Why is the while loop only performed twice like once with ping failing and once with ping succeeding? What do I have to change to get more dots added in the while loop?
I did the test also with a non existent IP. But it got stuck with
waiting for NonExistentServer...
and never terminated of course. But the same question why don't the
........ get added?