Ravi
Ravi

Reputation: 8209

Error while FTPing files

I'm getting the following error while executing the script. Don't know where I'm getting it wrong.

Error message:

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

Here is the script

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

Upvotes: 0

Views: 83

Answers (1)

Marc B
Marc B

Reputation: 360562

the terminator in a heredoc must be at the BEGINNING on a line, not indented:

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

should be

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

Since yours is indented, the heredoc is actually not terminated, and the shell parser simply runs off the end of the script, hence your unexpected end of file

Upvotes: 1

Related Questions