选择菜单
Posted 盛碗米饭
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了选择菜单相关的知识,希望对你有一定的参考价值。
#!/bin/sh
path=
/server/scripts
[ ! -d
"$path"
] &&
mkdir
$path
#menu
cat
<<END
1.[
install
lamp]
2.[
install
lnmp]
3.[
exit
]
pls input the num you want:
END
read
num
expr
$num + 1 &>
/dev/null
[ $? -
ne
0 ] && {
echo
"the num you input must be {1|2|3}"
exit
1
}
[ $num -
eq
1 ] && {
echo
"start installing lamp."
sleep
2;
[ -x
"$path/lamp.sh"
] || {
echo
"$path/lamp.sh does not exist or can not be exec."
exit
1
}
$path
/lamp
.sh
exit
$?
}
[ $num -
eq
2 ] && {
echo
"start installing LNMP."
sleep
2;
[ -x
"$path/lnmp.sh"
] || {
echo
"$path/lnmp.sh does not exist or can not be exec."
exit
1
}
$path
/lnmp
.sh
exit
$?
}
[ $num -
eq
3 ] && {
echo
bye.
exit
3
}
#[[ ! $num =~ [1-3] ]]&&{
[ ! $num -
eq
1 -o ! $num -
eq
2 -o ! $num -
eq
3 ] && {
echo
"the num you input must be {1|2|3}"
echo
"Input ERROR"
exit
4
}
以上是关于选择菜单的主要内容,如果未能解决你的问题,请参考以下文章