#!/bin/bash

DONE=0
(
  ping -c1 -n 8.8.8.8 &
  ping -c1 intranet.spintec.com &
  ping -c1 www.google.com &
  ( sleep 5; echo 'Network is unreachable' 2>/dev/null ) &
) |
while [ $DONE = 0 ] && read X
do
  if  echo $X | grep -q '^64 bytes from'
  then
    DONE=1
    echo OK
    exit 0
  elif echo $X | grep -q 'Network is unreachable'
  then
    exit 1 
  fi
done
