User Tools

Site Tools


tips:beep-when-host-starts-pinging

Beep when host starts pinging

This script will make the PC start beeping with the PC speaker when the selected host becomes pingable. It's useful for example when you are waiting for some server to come online and don't want to keep looking a terminal full of ping timeouts. Remember to check first that the beep command actually causes some noise.

#!/bin/bash
 
if [ $# -eq "1" ]; then
        beep -f 3000 -l 50
        for (( ; ; )) ; do
                pin=`ping -c 1 -w 1 "$1" | grep -c "bytes from"`
                if [ $pin -eq 1 ]; then
                        beep -f 3000 -l 50
                        echo "* `date +%H:%M:%S` online!"
                else
                        echo "`date +%H:%M:%S` timeout"
                fi
                sleep 2
        done
else
        echo "Target parameter missing!"
fi
tips/beep-when-host-starts-pinging.txt · Last modified: 31.08.2011 00:22 by vergo