Skip to content

Instantly share code, notes, and snippets.

@tskrynnyk
Created January 16, 2015 05:25
Show Gist options
  • Select an option

  • Save tskrynnyk/de803c372b47f730e4f8 to your computer and use it in GitHub Desktop.

Select an option

Save tskrynnyk/de803c372b47f730e4f8 to your computer and use it in GitHub Desktop.
function pwp() {
HOST2PING=${1:-212.77.100.101}
SLEEP_TIME=5s
LAST_ERR=127
clear
echo HOST: $HOST2PING
while true; do
ping -c1 -W5 $HOST2PING >/dev/null
ERR=$?
if [ "$LAST_ERR" -ne "$ERR" ]; then
LAST_ERR=$ERR
echo -ne "\n$(date '+%x, %X'): "
fi
case $ERR in
0) echo -n '+'; beep -f220 -l30
;;
1) echo -n '·';
;;
2) echo -n '×';
;;
*) echo -n 'Error'; exit
;;
esac
sleep $SLEEP_TIME;
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment