I'm using lftp
to connect to a FTP server and am trying to cd
into a specific directory, with that directory location saved as a variable, REMOTE_DIRECTORY
.
I'm pretty sure this isn't working because of the spaces in the name of the folders, but I've tried both single and double quotes, which haven't resolved the issues I'm getting. Not sure what else to try. This is what I've tried:
REMOTE_DIRECTORY="SRC Test Data"
export workdir=/home/ubuntu/tmp
lftp -u $USER,$PASS $HOST <<EOF
set ftp:ssl-protect-data true
set ftp:ssl-force true
set ssl:verify-certificate no
pwd
cd $REMOTE_DIRECTORY
pwd
cd 'SRC Test Data'
pwd
ls -d > $workdir/src_list
quit
EOF
The output of that script is:
ftp://FTP_User-RW:chars@sslftp.domain
Usage: cd remote-dir
ftp://FTP_User-RW:chars@sslftp.domain
ftp://FTP_User-RW:chars@sslftp.domain/SRC%20Test%20Data
So it clearly is working only when I explictly enter in the folder name in the cd
command. How do I do it though with the variable?