Search code examples
bashftpdownloadunzip

Cant do anything after ftp transfer


I wrote script for downloading zip files from ftp, and than unziping each different extension to own folder. download.sh

#!/bin/bash
ftp -in sitehere.com << EOF
user username pass
binary
hash
lcd ./temp
mget *.zip
bye
unzip -n './temp/*.zip' -d ../../base/images/ *.TIF
unzip -n './temp/*.zip' -d ../../base/dbfs/ *.dbf

But after downloading i have in terminal i have 2 errors "Unknown format". Tell me please what I doing wrong? Thanks.


Solution

  • Insert EOF at the end of the FTP command list. Without it the two unzip commands are sent to the FTP server.

    #!/bin/bash
    ftp -in sitehere.com << EOF
    user username pass
    binary
    hash
    lcd ./temp
    mget *.zip
    bye
    EOF
    
    unzip -n './temp/*.zip' -d ../../base/images/ *.TIF
    unzip -n './temp/*.zip' -d ../../base/dbfs/ *.dbf