2010-10-06 242 views
2

我在bash編程中很糟糕。錯誤在哪裏?這裏是我的.profile文件:。配置文件:第31行:語法錯誤:文件意外結束

# WARNING: For help understanding this file, and before you try 
# to change any of it, type "man .profile" and read carefully. 
# 

# 
# Set command search rules 
# 
if [ -x /bin/showpath ] ; then   
    export PATH; PATH=`/bin/showpath $HOME/bin /u/cs350/sys161/bin /software/gnu/bin standard` 
    export PATH; PATH=`/bin/showpath usedby=user standard $HOME/bin` 
# 
# Find out what kind of terminal we are using 
# 
    eval `setterm sytek:kd404 default:vc404` 
# 
# Set terminal-type dependent options (e.g. sysline or prompt string) 
# 
    #HOMEHOST="<hostname>" 
    #HOMEUSER="<userid>" 
    #export HOMEHOST HOMEUSER 
    PS1="$ " 
# 
# Now do the usual signing on things 
# 
    export MAIL; MAIL=${MAIL-"/usr/spool/mail/$USER"} 

if [ -r /software/.admin/bins/bin/read_system_news ] ; then /software/.admin/bins/bin/read_system_news ; fi 

EOF 

回答

5

你的第一if缺少fi

3

您錯過了fi文件末尾添加它。

也擺脫EOF。您的案例中的EOF被視爲命令。

有時使用不同的shell運行你的腳本會給你一個關於錯誤的線索。

當我們運行使用你的程序:

  • sh它說:Syntax error: end of file unexpected (expecting "fi")
  • csh它說:if: Expression Syntax.
+1

奔跑穿過CSH一個bash或sh腳本是保證給你的錯誤。這只是一個巧合,你顯示的錯誤似乎是相關的。 – 2010-10-06 06:50:17

+0

@丹尼斯:只有當你的bash腳本碰巧使用bash特定功能。 – codaddict 2010-10-06 13:13:17

+0

不,csh使用括號'if(condition)' - 不是方括號。 – 2010-10-06 13:46:03

相關問題