Don't like ads? PRO users don't see any ads ;-)
Guest

Bash testhelper

By: a guest on Apr 14th, 2012  |  syntax: Bash  |  size: 0.47 KB  |  hits: 76  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. TIME=1
  10. i=0
  11. while [ 1 ]; do
  12.         ping 192.168.1.1 -c 1
  13.         if [ $? != 0 ]; then
  14.                 echo "Ping was not sended"
  15.                 let i=i+1
  16.                 if [ $i = 10 ]; then
  17.                         echo "goes shutdown"
  18.                         break
  19.                 fi
  20.         else
  21.                 echo "Ping sended"
  22.                 let i=0
  23.         fi
  24.         sleep $TIME;
  25. done
  26.  
  27. echo $i
  28.  
  29. echo "command: shutdown"