How to determine in a shell script that remote host is up?

I want to create a shell script that waits for a certain host to be up. I am using QNX 6.1.
Thanks,
CP

while true
do
  ping -c 1 -w 1 remotehost
  if [ $? -eq 0 ]
  then
    echo "remotehost is up"
    break
  else
    echo "sleep and try again in 5 seconds"
    sleep 5
  fi
done

Thanks.