- 论坛徽章:
- 0
|
使用shell实现精致菜单<各路大虾请进...>
select , 專門做菜單用的 。只是移植性差 ,之適合 ksh 和 bash。
#!/bin/bash
OPTIONS="Route Ls iptables iptablesADD iptablesDEL Quit"
select opt in $OPTIONS; do
if [ "$opt" = "Quit" ]; then
#echo done
echo ByeBye
exit
elif [ "$opt" = "Route" ]; then
route -n
elif [ "$opt" = "Ls" ]; then
ls -l
elif [ "$opt" = "iptables" ]; then
iptables -t nat -L
elif [ "$opt" = "iptablesADD" ]; then
echo -n " lease input IP:"
read IP
iptables -t nat -A POSTROUTING -s $IP -j MASQUERADE
elif [ "$opt" = "iptablesDEL" ]; then
echo -n " lease input number:"
read DIP
iptables -t nat -D POSTROUTING -s "$DIP"/32 -j MASQUERADE
else
clear
echo bad option
fi
done |
|