因為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
沒有留言:
張貼留言