Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function loop-until-up() {
- until nmap -sn $1 | grep "Host is up" > /dev/null ; do
- sleep 5s
- done
- }
- function alarm-while-up() {
- while nmap -sn $1 | grep "Host is up" > /dev/null ; do
- printf '\7'
- sleep 2s
- done
- }
- function main() {
- echo Waiting for $1...
- loop-until-up $1
- echo -n $1 went UP at
- date +" %H:%M, %a, %m/%d/%g"
- alarm-while-up $1
- echo -n $1 went back down at
- date +" %H:%M, %a, %m/%d/%g"
- main $1
- }
- if [ -z $1 ] ; then
- echo Missing IP address
- else
- main $1
- fi
Advertisement