R
R
Ras2018-08-22 17:58:41
bash
Ras, 2018-08-22 17:58:41

Bash: Why doesn't EOF in if work?

Good afternoon.
Bash experts tell me why the following construction does not work? (swears at EOF)
If you remove the check, everything works, googled, tried the tips found, but nothing.

if [ "$doUpload" = "upload" ];
then    
    lftp -u $ftpUser,$ftpPassword $ftpServer <<EOF
    set ftp:ssl-protect-data true
    set ssl:verify-certificate no
    put $backupName.tar.gz
    bye
    EOF    
fi
exit 0

Error itself:
backup.sh: line 182: warning: here-document at line 152 delimited by end-of-file (wanted `EOF')
backup.sh: line 183: syntax error: unexpected end of file

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2018-08-22
@Ras

But it’s not good to do decorations.
EOF must be at the very beginning of the line.

A
AVKor, 2018-08-22
@AVKor

<<- EOF

S
Saboteur, 2018-08-27
@saboteur_kiev

CMD="set ftp:ssl-protect-data true
set ssl:verify-certificate no
put $backupName.tar.gz
bye"

if [ "$doUpload" = "upload" ];
then    
    lftp -u $ftpUser,$ftpPassword $ftpServer<<<"${CMD}"
fi
exit 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question