歡迎您光臨本站 註冊首頁

請教各位大俠,關於Shell文本編譯時的問題

←手機掃碼閱讀     火星人 @ 2014-03-22 , reply:0

這個是shell文本
#!/bin/sh


echo "Is it morning? Please answer yes or no:"

read timeofday

if [ "$timeofday" = "yes" ]; then

echo "Good morning"

elif [ "$timeofday" = "no" ]; then

echo "Good afternoon"

else

echo "Sorry, $timeofday not recognized. Enter yes or no"

exit 1

fi

exit 0



本來有錯的,我看著改了錯誤,編譯時出現了問題,大家看下
win@ubuntu:~$ chmod +x elif2
win@ubuntu:~$ ./elif2
: not found
Is it morning? Please answer yes or no:
yes
: bad variable name
./elif2: 7: Syntax error: "elif" unexpected (expecting "then")


這是為啥阿,幾乎所有這類程序都是這種錯誤

[火星人 ] 請教各位大俠,關於Shell文本編譯時的問題已經有545次圍觀

http://coctec.com/docs/linux/show-post-104236.html