|| at Jul 30, 2008 at 6:50 am
Can't resist posting the parallel version of this:
if [ "$#" == "1" ]
ping -c2 $1 &> /dev/null
if [ $? = 0 ] ; then
printf "%-30s is alive \n" $1
printf "%-30s is not alive \n" $1
for n in $*
$0 $n &
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.