Posted By

sudarkoff on 08/28/06


Tagged

Bash network geektool internet status


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

yuconner


Ping random IP to see if there's connection


 / Published in: Other
 

URL: http://projects.tynsoe.org/phpBB2/viewtopic.php?p=745

  1. One that just checks a random IP on the internet to see if we have internet access:
  2. Code:
  3.  
  4. shopt -s extglob
  5. GW=216.239.32.10
  6. IFS=''
  7. PING=`ping -c1 -n -t5 -o $GW`
  8. RC=$?
  9. if [ $RC -eq 2 ]; then
  10. echo "Internet ($GW) no reply"
  11. exit 1
  12. fi
  13. RT=$( echo $PING | head -n2 | tail -n1 | awk -F= '{print $4}' )
  14. echo "Internet ($GW) $RT"
  15. exit $RC

Report this snippet  

You need to login to post a comment.