Thursday, April 9, 2009

Bash Script to check internet connectivity

Today I decided to search for Linux website/blog LinuxScrew.

Here is example from website of very simple bash script to check internet connection:

#!/bin/bash

WGET="/usr/bin/wget";

$WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
if [ ! -s /tmp/index.google ];then
echo "no"
else
echo "yes"
fi

No comments:

Post a Comment