bashlftp

lftp bash script end of file unexpected


I'm trying to put the result in a variable but it didn't work Syntax error: end of file unexpected (expecting ")")

#!/bin/bash
test="$(lftp -u ns454575.ip-154-145-259.eu,NGFYv85MTI ftpback-rbx2-588.mybackup.ovh.net << EOF
cd /backup/site
ls
bye
EOF)"

enter image description here


Solution

  • You shouldn't add something after here docs. You can validate this by using shellcheck.

    #!/bin/bash
    test="$(lftp -u ns454575.ip-154-145-259.eu,NGFYv85MTI ftpback-rbx2-588.mybackup.ovh.net <<-EOF
    cd /backup/site
    ls
    bye
    EOF
    )"
    

    p.s. you know that test is a command as well? :-)