Linux Ftp mput 命令示例
时间:2010-11-15 来源:刘政道
#!/bin/sh
#cd
ftp -n -i 192.168.0.1 <<EOF
user username userpassword
passive
cd /jbpm
prompt
prompt
mput /var/lib/mysql/jbpm/*.* jbpm2010
quit
EOF
exit
结果FileZilla报550错.
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> STOR /var/lib/mysql/jbpm/qdcm_pow_items.frm
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 550 Filename invalid
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> PORT 192,168,0,1,36,148
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 200 Port command successful
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> STOR /var/lib/mysql/jbpm/qdcm_pow_sh.frm
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 550 Filename invalid
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> PORT 192,168,0,1,36,149
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 200 Port command successful
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> STOR /var/lib/mysql/jbpm/qdcm_tool_note.frm
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 550 Filename invalid
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> PORT 192,168,0,1,36,150
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 200 Port command successful
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> STOR /var/lib/mysql/jbpm/test.frm
(000026) 2010-11-15 10:48:12 - dai (10.130.129.11)> 550 Filename invalid
尝试了好多把后,在网上搜了N吧,可能原因是路径/var/lib/mysql/jbpm/*.*,在脚本前加入 cd /var/lib/mysql/jbpm/,然后再mput *.* 就不报错了。原来FileZilla默认将/var/lib/mysql/jbpm/作为保存路径,在FTP服务器上自然就找不到这个路径。修改后就不报错了。
在Linux代码中使用prompt的目的是将Interactive mode 设置成off,这样的话在传文件时就不会有询问yes/no对话框。
每次使用prompt时,Interactive mode的状态就会改变,prompt on 或 off命令不起作用,并不能达到预期效果。