首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

shell有关问题!求教

2012-04-10 
shell问题!求教!#!/bin/shecho Is morning ? Please answer yes or noread timeofecho $timeofif [ $ti

shell问题!求教!
#!/bin/sh
echo "Is morning ? Please answer yes or no"
read timeof

echo $timeof
if [ "$timeof"="no" ];then
 echo "Good morning"
elif [ "$timeof"="yes" ];then
 echo "Good afternoon"
else
 echo "Sorry, $timeof is not rencognized. Enter yes or no"
 exit 1
fi
exit 0

为什么不管怎么输入都显示输出Good morning 哪里错啦?



[解决办法]
= 两边留个空格
[解决办法]
主要是判断语句里面的等号两边漏下空格了。

JScript code
#!/bin/shecho "Is morning ? Please answer yes or no"read timeofif [ $timeof = "yes" ];then        echo "Good morning"elif [ $timeof = "no" ];then        echo "Good afternoon"else        echo "Sorry, $timeof is not rencognized. Enter yes or no"fi 

热点排行