2009年12月14日

自動重開機並記錄重開次數的Script

為了要測試重開機幾次會失敗, 寫了一個script來記算.
因為busybox的shell只提供了有限的功能, 不能像bash一樣宣告整數變數, 所以count的處理算比較麻煩.
#!/bin/sh
FILE=/etc/count
timeout=2

if [ ! -f  $FILE ] ; then
    echo 0 > $FILE
fi

count=`cat $FILE`
#echo $count
echo $(($count+1)) > $FILE

echo "================================================"
echo "Success reboot times :" `cat $FILE`
echo "Ctrl+C to break"
echo "================================================"

# setup timeout
old_tty_settings=`stty -g`
stty -icanon min 0 time ${timeout}0
eval read $input
stty "$old_tty_settings"

echo "reboot"
reboot

沒有留言:

coap-client 4.3.0 Windows build

coap-client  is a  wget -like tool to generate simple requests for retrieval and modification of resources on a remote server.  Got the sour...