Skip to content

Instantly share code, notes, and snippets.

@neochrome
Created September 16, 2020 11:46
Show Gist options
  • Save neochrome/60eeed34f339c79467fee925612f4744 to your computer and use it in GitHub Desktop.
Save neochrome/60eeed34f339c79467fee925612f4744 to your computer and use it in GitHub Desktop.
netcheck
#!/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