You might going to find yourself in a situation where you need to be able to do an action if a certain host is available or disconnected from the network. 

Here are 2 bash scripts what can help you achieve this

The first script will ping the HOST until it's unavailable on the network.

#!/bin/bash
# Ping until host is down!
UNREACHEABLE=0;
while [ $UNREACHEABLE -ne "2" ]; 
   do ping -q -c 1 pampog.com &> /dev/null; UNREACHEABLE=$?; echo "Establishing connection, host is UP! "$UNREACHEABLE; sleep 1;
done
echo "Host is DOWN!";

The second script will ping the HOST until it's available on the network, and then it exits.

#!/bin/bash
# Ping until host is UP!.
UNREACHEABLE=1;
while [ $UNREACHEABLE -ne "0" ]; 
   do ping -q -c 1 pampog.com &> /dev/null; UNREACHEABLE=$?; echo "Establishing communication with Host..."; sleep 1;
done
echo "Host is UP!";