我无法通过我制作的BATCH文件连接并将文件上传到某个ftp。
另外,我想上传本地目录中的所有文件。
请你的帮助!
感谢。
代码:
@echo off
echo user username>> ftpcmd.dat
echo pass>> ftpcmd.dat
echo cd /public_html/reports/>> ftpcmd.dat
echo mput C:\automation\tests\HtmlReporter\*>> ftpcmd.dat
ftp -n -s:ftpcmd.dat myserver.com
del ftpcmd.dat
echo quit>> ftpcmd.dat
pause
disconnect
bye
错误:
Connected to MYSERVER.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 23 of 500 allowed.
220-Local time is now 05:30. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
ftp> user USERNAME
331 UserUSERNAME OK. Password required
230-OK. Current restricted directory is /
230-111 files used (1%) - authorized: 10000 files
230 17049 Kbytes used (1%) - authorized: 1536000 Kb
ftp> prompt
Interactive mode Off .
ftp> cd /public_html/reports/
250 OK. Current directory is /public_html/reports
ftp> mput C:\automation\tests\HtmlReporter\*
Error opening local file C:\automation\tests\HtmlReporter\..
Error opening local file C:\automation\tests\HtmlReporter\...
200 PORT command successful
答案 0 :(得分:2)
看看这一行:
password
这实际上不会将password_
存储在dat文件中,而是>>
(_是空格)。尝试在echo user username>> ftpcmd.dat
echo password>> ftpcmd.dat
echo /public_html/reports>> ftpcmd.dat
echo mput c:\workspace\automation\HtmlReporter\Test_Report.html>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat servernamet.com
del ftpcmd.dat
pause
disconnect
bye
之前删除空格:
@echo off
{{1}}