Geeklet script to ping hosts I have found the nice script below to ping a host to check if it is up or down. However I haven't found a way (and my very basic programming knowledge has failed me here) on how I can ping multiple servers. Ideally I'd go HOST1= XXX, HOST2=YYY etc...

Could someone point me in the right direction? I have about 10 hosts I'd like to see the up/down status for. Geektool script copied from macosxtips.co.uk

HOST=typehostnamehere
PING=`ping -q -c 1 $HOST`
if [[ $? -eq 0 ]] ; then
    TIME=`echo $PING |tail -1 | cut -d/ -f 5`
    echo ${TIME}ms away from $HOST
    exit 0
else
    echo $HOST could not be reached
    exit 2
fi
You want to read up on loops in bash scripts.

For example:

HOSTS="hosta
hostb
hostc"

for machine in $HOSTS
do
  PING=`ping -q -c 1 $machine`
  if [[ $? -eq 0 ]] ; then
    TIME=`echo $PING |tail -1 | cut -d/ -f 5`
    echo ${TIME}ms away from $machine
  else
    echo $machine could not be reached
  fi
done


I didn't test that, but it's close enough. Replace the HOSTS list with the list of hosts you want to report on.