0

执行脚本时出现以下错误。不知道我哪里弄错了。

错误信息:

./ftp_send_script.sh: line 40: syntax error: unexpected end of file

这是脚本

#!/usr/bin/bash

#Define Variables
#------------------------------------------------------------------------------

HOST=qftpserver
USER=ftpuser
PASS=password

#------------------------------------------------------------------------------

#FTP files
#------------------------------------------------------------------------------
for FILE in `ls *.txt`
do
        ftp -n -p << EOT
        open $HOST
        user $USER $PASS
        prompt n
        type binary
        mput ${FILE}
        quit
        EOT
echo ${FILE}
done
#------------------------------------------------------------------------------
4

1 回答 1

1

heredoc 中的终止符必须在一行的开头,而不是缩进:

for FILE in `ls *.txt`
        ...
        mput ${FILE}
        quit
        EOT

应该

for FILE in `ls *.txt`
     ...
     mput ${FILE}
     quit
EOT    <---start in column 0, not indented.

由于你是缩进的,heredoc 实际上并没有终止,shell 解析器只是在脚本的末尾运行,因此你的unexpected end of file

于 2012-11-19T14:52:13.790 回答