Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Usage ./updown.sh x.x.x.x
- function hostUp() {
- msg="\"$1 is UP\""
- osascript -e "display notification ${msg} with title \"Host UP\""
- }
- function hostDown() {
- msg="\"$1 is DOWN\""
- osascript -e "display notification ${msg} with title \"Host DOWN\""
- }
- function is_alive() {
- ping -c 1 $1 > /dev/null
- if [ $? -eq 0 ] ;then
- result=1
- else
- result=0
- fi
- }
- state=-1
- for (( ; ; ))
- do
- is_alive $1
- if [ $result -ne $state ]; then
- if [ $result -eq 1 ]; then
- hostUp $1
- else
- hostDown $1
- fi
- fi
- state=$result
- sleep 10
- # echo "infinite loops [ hit CTRL+C to stop]"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement