Test Connection to an Address

This script tests ping to http://www.puchufy.com. If the result is 100%, it means there is 100% packet loss.

To test, save this as .sh file.


#!/bin/bash
###########################################
### MONITOR CONNECTION TO EXTERNAL SITE ###
###########################################

CONN=`ping -c5 -I eth0 www.puchufy.com | grep -oP '\d+(?=% packet loss)'`

if [ $CONN -eq 0 ]
   then
   result="SUCCESS"    
else
   result="FAILED"
fi