FTP文件时出错

时间:2012-11-19 14:49:28

标签: bash unix ftp

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

错误讯息:

./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
#------------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:1)

heredoc中的终结符必须位于行上的BEGINNING,而不是缩进:

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