I am trying to delete a file from an FTP server in a shell script using LFTP, but for some reason it will not use my variables and accepts them as literals.
The code:
USERNAME="theuser" PASSWORD="verygoodpassword" SERVER="example.com" BACKUPDIR="thebackups" FILETODELETE="uselessfile.obsolete" lftp -e 'rm /${BACKUPDIR}/${FILETODELETE}; bye' -u $USERNAME,$PASSWORD $SERVER
I want it to run:
lftp -e 'rm /thebackups/uselessfile.obsolete; bye' -u theuser,verygoodpassword example.com
But instead, it starts:
lftp -e 'rm /${BACKUPDIR}/${FILETODELETE}; bye' -u theuser,verygoodpassword example.com
And because of this, he cannot find the literal file "/ $ {BACKUPDIR} / $ {FILETODELETE}" on the FTP server and complains in this way.
What am I doing wrong?
Hurrah!
source share