Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- if [ -e /tmp/ping-test.pid ]
- then
- echo "script already running"
- exit 1;
- fi
- PID=$$
- HOST=$1
- COUNTER=0
- echo $PID >> /tmp/ping-test.pid
- while [ $COUNTER -lt 5 ];
- do
- let COUNTER+=1
- ping -c1 $HOST
- if [ $? -eq 0 ]
- then
- echo "OK"
- rm /tmp/ping-test.pid
- exit 0
- else
- echo "ERROR"
- sleep 1
- fi
- done
- echo "FAIL"
- rm /tmp/ping-test.pid
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement