Advertisement
Guest User

Bash testHelper 1

a guest
Apr 15th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. # Bash testHalter for linux/haiku
  2. #
  3. # caka dobu (sekund), ak 10 za sebou pingov
  4. # su neposlanych, potom spusti halt.
  5. #
  6. # try 10 pings and when they are not sended,
  7. # then run halt
  8.  
  9. declare IP
  10. declare -i TIME
  11.  
  12. # Tested IP adress
  13. IP='192.168.9.7'
  14.  
  15. # Time between two pings
  16. TIME=1
  17.  
  18. i=0
  19.  
  20. while [ 1 ]; do
  21.     ping "$IP" -c 1
  22.     if [ $? -ne 0 ]; then
  23.         echo "Ping was not sent"
  24.         let i=i+1
  25.         if [ $i -eq 10 ]; then
  26.             echo "goes shutdown"
  27.             break
  28.         fi
  29.     else
  30.         echo "Ping sent"
  31.         let i=0
  32.     fi
  33.     sleep $TIME;
  34. done
  35.  
  36. echo $i
  37.  
  38. echo "command: shutdown"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement