Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. if [ -e /tmp/ping-test.pid ]
  4. then
  5. echo "script already running"
  6. exit 1;
  7. fi
  8.  
  9. PID=$$
  10. HOST=$1
  11. COUNTER=0
  12.  
  13. echo $PID >> /tmp/ping-test.pid
  14.  
  15. while [ $COUNTER -lt 5 ];
  16. do
  17. let COUNTER+=1
  18. ping -c1 $HOST
  19. if [ $? -eq 0 ]
  20. then
  21. echo "OK"
  22. rm /tmp/ping-test.pid
  23. exit 0
  24. else
  25. echo "ERROR"
  26. sleep 1
  27. fi
  28. done
  29.  
  30. echo "FAIL"
  31. rm /tmp/ping-test.pid
  32. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement