Last active
July 13, 2016 21:15
-
-
Save Skymetal/c9b0063da9404f1280b993e6c4ef20f5 to your computer and use it in GitHub Desktop.
bash: ping google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
while : | |
do | |
date | tr -d '\n' | |
VAL=`ping -c 5 www.google.com | tail -1 | awk '{print $4}' | cut -d '/' -f 2` | |
if [[ -z "${VAL// }" ]] | |
then | |
printf " == ${RED}ERR" | |
sleep 5 | |
else | |
printf " == ${GREEN}$VAL" | |
sleep 20 | |
fi | |
printf "${NC}\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment