
Bash testHelper 1
By: a guest on
Apr 15th, 2012 | syntax:
Bash | size: 0.56 KB | hits: 31 | expires: Never
# Bash testHalter for linux/haiku
#
# caka dobu (sekund), ak 10 za sebou pingov
# su neposlanych, potom spusti halt.
#
# try 10 pings and when they are not sended,
# then run halt
declare IP
declare -i TIME
# Tested IP adress
IP='192.168.9.7'
# Time between two pings
TIME=1
i=0
while [ 1 ]; do
ping "$IP" -c 1
if [ $? -ne 0 ]; then
echo "Ping was not sent"
let i=i+1
if [ $i -eq 10 ]; then
echo "goes shutdown"
break
fi
else
echo "Ping sent"
let i=0
fi
sleep $TIME;
done
echo $i
echo "command: shutdown"