Sunday, July 15, 2012

Notifty when a computer is on

This function pings the givem IP once in every 10 mins. When ping succeeds it does echo and gives a bubble notification in ubuntu

function notify_when_on {
 ping -w1 $1 &> /dev/null
 RC=$?
 while [ $RC -eq 1 ]
 do
  sleep 600
  ping -w1 $1 &> /dev/null
  RC=$?
 done
 mesg="$1 is ON"
 echo ${mesg}
 notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "${mesg}"
}
Add this function to .bashrc and use it as
notify_when_on 172.24.56.143

No comments: