【发布时间】:2014-11-17 01:05:13
【问题描述】:
如何编写bash脚本,如果输入空值“”,或者1和2以外的其他值不会结束脚本,并且会让用户租用1或2。如果用户输入错误,会让用户租用租客。
echo Press 1 for services and 2 for chkconfig?
echo -n "Please input yes or no: "
read ANS
if [ $ANS != "" ];
if [ $ANS == 1 ];
then
service vsftpd status
elif [ $ANS == 2 ];
then
service vsftpd status
else
echo please input 1 oe 2
fi
~
【问题讨论】: