Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

<<EOF ... syntax error: unexpected end of file

1,155 views
Skip to first unread message

bandejapaisa

unread,
Mar 2, 2009, 6:03:27 PM3/2/09
to
Im backing up my databases, and ftp'ing the files to a backup server:

#Loop over databases and backthem up
for DB in ${DBNAMES[@]}; do

#1. Backup the database
BACKUPFILE="/var/backups/mysql/$DB.$DATE.sql"
echo "Backing up $DB to $BACKUPFILE ..."
mysqldump --user=$USER --password=$PASSWORD --opt $DB >
$BACKUPFILE

#2. Compress the backedup file and delete the original
echo "Compressing the backup file ..."
tar -czf "${BACKUPFILE}.tgz" $BACKUPFILE
rm -rf $BACKUPFILE

#3. FTP to backup server
echo "Going to send the file to backup server ...."
ftp -n -v $FTP_HOSTNAME <<EOF
binary
user $FTP_USERNAME $FTP_PASSWORD
prompt
put ${BACKUPFILE}.tgz
bye
EOF
done


However.... the ftp section doesn't seem to be working and i get the
error:

line 48: syntax error: unexpected end of file

Line 48 being the last line in my file. It seems that my EOF tag is
not terminating the multi line string.

Any ideas what im doing wrong?

Thanks

bandejapaisa

unread,
Mar 2, 2009, 6:11:44 PM3/2/09
to
I figured it out....

Firstly, the marker EOF needed to have NO leading whitespace....
secondly, it didn't like me using the letters EOF.

I changed it to something else (HERE) and it worked !

Barry Margolin

unread,
Mar 4, 2009, 1:40:22 AM3/4/09
to
In article
<9a682a3a-392c-432d...@v19g2000yqn.googlegroups.com>,
bandejapaisa <djcas...@googlemail.com> wrote:

You're correct about the leading whitespace. But I've used "EOF" as the
end marker many times, so you're confused there.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Richard van der Leeden

unread,
Mar 4, 2009, 9:24:10 AM3/4/09
to
Barry Margolin wrote:
> In article
> <9a682a3a-392c-432d...@v19g2000yqn.googlegroups.com>,
> bandejapaisa <djcas...@googlemail.com> wrote:
>
>> I figured it out....
>>
>> Firstly, the marker EOF needed to have NO leading whitespace....
>> secondly, it didn't like me using the letters EOF.
>>
>> I changed it to something else (HERE) and it worked !
>
> You're correct about the leading whitespace. But I've used "EOF" as the
> end marker many times, so you're confused there.
>

You can use leading tabs if you use the redirection operator <<-

e.g.

for loop in 1 2
do
cat <<-EOF
stuff
EOF
done


and yes no problem with using "EOF".

bandejapaisa

unread,
Mar 5, 2009, 11:55:19 AM3/5/09
to
Ahhh nice <<- allows me to keep my nice formatted code.


Just checked EOF again. Working now.

Thanks

mrchad...@gmail.com

unread,
Jun 11, 2014, 1:55:12 AM6/11/14
to
Hi,

I am facing the problem with EOF..
What the correction I have to do?
0 new messages