mercredi 6 mai 2015

Error with fi in if then else shell script

There is a shell script with if, then, else. Here is the part of the code, it's not the whole, just the part:

DAYOFWEEK=$(date +"%u")
echo $DAYOFWEEK
if [ "$DAYOFWEEK" -eq 1 ]; then
echo "OK. It's Monday. We are running a weekly backup on Mondays."

echo "`date` - Deleting weekly remote backup files."
sftp -oPort=199 $SFTPUSER@$SFTPSITE <<EOF;
    cd user;
    cd weekly;
    ls -al;
    rm *;
    bye;
    EOF;
    echo "DONE"
rsync -ave "ssh -p 199" /root/backups/files/$THESITE/daily/ 
root@coolsite.org:/root/user/weekly
else
 echo "No weekly backups today"
fi

I get en error:

./backup.sh: 120: ./backup.sh: Syntax error: end of file unexpected (expecting "fi")

root@developementbox:~/backups#

It doesn't like fi and I don't understand what is wrong with this.

Aucun commentaire:

Enregistrer un commentaire