[英]Cannot upload files and folders in directory via FTP in batch script
我有几个文件夹希望通过 FTP 上传到服务器。
这是文件夹结构:
build >
fonts >
- font1.ttf
- font2.ttf
images >
- img1.png
- img2.png
javascripts >
- script.js
stylesheets >
- style.css
index.html
我有fileup.bat
:
@echo off
echo user USERNAME> ftpcmd.dat
echo PASSWORD>> ftpcmd.dat
echo prompt>> ftpcmd.dat
echo cd %1>> ftpcmd.dat
echo lcd %2>>ftpcmd.dat
echo mput *.*>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat 123.456.78.9
del ftpcmd.dat
pause
run_ftp.bat
是一行, public_html/
是服务器上文件的目的地, C:\Web\build
是文件在我的电脑上的位置:
fileup public_html/ C:\Web\build
run_ftp.bat
位于 C:\Web 中, fileup.bat
位于 C:\Windows 中,因此它出现在 PATH 中,我可以在 ZDFFF0A7FA1A55C8C1452ZZFDA6 中运行 fileup。
当我运行run_ftp.bat
时,上传到服务器的唯一文件位于 /build 的根目录中,因此仅上传 index.html。 控制台日志: Error opening local file fonts.
对于 /build 中的每个文件夹。
这是日志:
230 OK. Current restricted directory is /
ftp> prompt
Interactive mode Off .
ftp> cd public_html/
250 OK. Current directory is /public_html
ftp> lcd C:\Web\build
Local directory now C:\Web\build.
ftp> mput *.*
Error opening local file fonts.
Error opening local file images.
200 PORT command successful
150 Connecting to port 57128
226-File successfully transferred
226 0.142 seconds (measured here), 1.78 Mbytes per second
ftp: 265174 bytes sent in 0.07Seconds 3682.97Kbytes/sec.
Error opening local file javascripts.
Error opening local file stylesheets.
200 PORT command successful
150 Connecting to port 57129
226-File successfully transferred
226 0.033 seconds (measured here), 36.90 Kbytes per second
ftp: 1229 bytes sent in 0.01Seconds 102.42Kbytes/sec.
ftp> quit
221-Goodbye. You uploaded 261 and downloaded 0 kbytes.
221 Logout.
Press any key to continue . . .
当我运行 .bat 文件时,构建文件夹中的所有文件都不是正在使用的文件夹,我有点难过为什么没有上传任何文件夹。 我试过用ascii
替换bin
但它什么也没做。
Windows 命令行ftp.exe
客户端不支持递归操作。
您必须使用第 3 方 FTP 客户端。
例如,您可以使用WinSCP :
winscp.com /log=ftp.log /command ^
"open ftp://USERNAME:PASSWORD@ftp.example.com/" ^
"mput ""%2\*"" ""%1""" ^
"exit"
有将 Windows ftp.exe
脚本转换为 WinSCP 脚本的指南。 虽然更简单的是让WinSCP GUI 为您生成脚本或批处理文件。
(我是WinSCP的作者)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.