我编写了从ftp下载zip文件的脚本,而不是将每个不同的扩展名解压缩到自己的文件夹。 的 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
但下载后我在终端有2个错误“未知格式”。 请告诉我,我做错了什么? 感谢。
答案 0 :(得分:2)
在FTP命令列表的末尾插入EOF
。没有它,两个unzip
命令将被发送到FTP服务器。
#!/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
答案 1 :(得分:1)
您不需要关闭heredoc吗?即,如果要从ftp断开连接,请将EOF
放在单独的行上。
答案 2 :(得分:0)
ftp -n 192.168.1.111<<EOF
user USERNAME
pass PASSWORD
prompt off
mput file1.txt
bye
EOF
ftp -n 192.168.9.122<<EOF
user USERNAME
pass PASSWORD
prompt off
mput file2.txt
bye
Second file i.e. file2 is not getting uploaded