shell脚本运行异常
#!/bin/bash#program:#thisprogramshowstheuser'schoice#history:#2011/3/30dongfirstrelea...
#!/bin/bash
#program:
# this program shows the user's choice
#history:
#2011/3/30 dong first release
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH
read -p "please input (Y/N):" yn
if [ "$yn"=="Y" ]||[ "$yn"=="y" ]; then
echo "ok,contiue"
exit 0
fi
if [ "$yn"=="N" ]||[ "$yn"=="n" ]; then
echo "oh,interrupt!"
exit 0
fi
echo " i don't know what your choice is " && exit 0
初学者从鸟哥的linux私房菜摘来的shell脚本
当我运行时不管输什么都提示ok,continue
请高手看看错误在哪
本人在ubuntu10.04运行此脚本 展开
#program:
# this program shows the user's choice
#history:
#2011/3/30 dong first release
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH
read -p "please input (Y/N):" yn
if [ "$yn"=="Y" ]||[ "$yn"=="y" ]; then
echo "ok,contiue"
exit 0
fi
if [ "$yn"=="N" ]||[ "$yn"=="n" ]; then
echo "oh,interrupt!"
exit 0
fi
echo " i don't know what your choice is " && exit 0
初学者从鸟哥的linux私房菜摘来的shell脚本
当我运行时不管输什么都提示ok,continue
请高手看看错误在哪
本人在ubuntu10.04运行此脚本 展开
2个回答
展开全部
要么是你抄书的时候抄错了,要么就是鸟哥那本书写错了,在 if 语句那里的用法是错误的。
看我下面改后的脚本。
#!/bin/bash
read -p "please input (Y/N):" yn
if [ "$yn" = "Y" -o "$yn" = "y" ]; then
echo "ok,contiue"
exit 0
fi
if [ "$yn" = "N" -o "$yn" = "n" ]; then
echo "oh,interrupt!"
exit 0
fi
echo " i don't know what your choice is " && exit 0
看我下面改后的脚本。
#!/bin/bash
read -p "please input (Y/N):" yn
if [ "$yn" = "Y" -o "$yn" = "y" ]; then
echo "ok,contiue"
exit 0
fi
if [ "$yn" = "N" -o "$yn" = "n" ]; then
echo "oh,interrupt!"
exit 0
fi
echo " i don't know what your choice is " && exit 0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询