Created
September 16, 2020 11:46
-
-
Save neochrome/60eeed34f339c79467fee925612f4744 to your computer and use it in GitHub Desktop.
netcheck
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
#!/usr/bin/env bash | |
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
blue=$(tput setaf 4) | |
reset=$(tput sgr0) | |
while true; do | |
ERROR=$(ping -q -c 1 -W 10 google.com 2>&1 1>/dev/null) | |
printf "[${blue}%s${reset}] " $(date +'%H:%M') | |
if [[ -z "$ERROR" ]]; then | |
printf "${green}OK${reset}\n" | |
else | |
printf "${red}%s${reset}\n" "${ERROR}" | |
fi | |
sleep 6 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment