bash EOF in if statement

Arthur picture Arthur · Feb 19, 2012 · Viewed 11.5k times · Source

I am trying to do an action in a IF ELSE statement in Bash, but receive an error like this one:

Syntax error: end of file unexpected (expecting "fi")

Now I am quite new to this, so probably the solution to my problem should not be that difficult :)

if [ "$DAYNAME" = 'Sunday' ]; then
    echo 'The backup will be uploaded'
    ftp -n $HOST <<EOF
        quote USER $USER
        quote PASS $PASSWD
        put $filetoday
        delete ${filethreeweeksago}
        quit
    EOF
fi

Of course the vars are already filled.

I think it has to do with the EOF notation, because when i remove them, the problem disapears. Unfortunatly I don't know how to use the code without the EOF notation.

Can anyone tell me why this error is comming up?

Answer

cnicutar picture cnicutar · Feb 19, 2012

Drop the blanks and it should work:

    EOF
^^^^