最典型的shell case命令匹配命令行,啟動腳本的start|stop|restart|status處理
case "$@" in
($@ 字符串數組:以"參數1" "參數2" ... 的字符串數組形式保存所有參數
對于單個參數的情況,$@就一個字符串)
start)
echo -n "Starting firewall..."
。。。
echo "OK!"
exit 0
;;
stop)
echo -n "Stopping firewall..."
。。。
exit 0
;;
restart)
$0 stop $0即執(zhí)行原始程序
$0 start
;;
status)
clear
echo ">------------------------------------------"
iptables -L
echo ">------------------------------------------"
iptables -t nat -L POSTROUTING
exit 0
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
posted on 2012-04-24 23:08
kxbin 閱讀(238)
評論(0) 編輯 收藏 所屬分類:
Linux