Can't resist posting the parallel version of this:
#!/bin/bash
if [ "$#" == "1" ]
then
ping -c2 $1 &> /dev/null
if [ $? = 0 ] ; then
printf "%-30s is alive \n" $1
else
printf "%-30s is not alive \n" $1
fi
else
for n in $*
do
$0 $n &
done
wait
fi
This does the same thing as the parent post, but (a) takes the IP
addresses as command-line arguments (i.e. call like this: "myscript
192.168.1.1 192.168.1.2 192.168.1.3"), and (b) dispatches the pings in
parallel so that you get the response from all the hosts quicker.
The responses are displayed in the order they return, but you could put
it through a sort if you wanted them ordered.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos