繁体   English   中英

如何创建.BAT文件以从HTTP \\ ftp服务器下载文件?

[英]How to create a .BAT file to download file from HTTP\ftp server?

如何创建.BAT文件以从FTP服务器下载文件或文件夹? (并用现有文件替换)(我们有像ftp://me:mypass@example.com/file.file (或http://example.com/file.file )这样的链接和像C:\\Users\\UserName\\Some mixed Русский English Adress\\file.file绝对文件链接C:\\Users\\UserName\\Some mixed Русский English Adress\\file.file )(仅使用本机Windows(xp vista win7等)BAT功能和文件)

以下是如何自动化内置ftp.exe工具的示例:

示例是关于上传,但原理是相同的(只使用get而不是put )。

但是,由于这只是“管道命令”到ftp.exe中,我建议不要为生产质量的批处理文件(没有错误处理等)执行此操作,而是使用一些外部工具。 我提供此答案只是因为您明确要求使用仅使用Windows内置命令的解决方案。

编辑:这是一个具体的例子:

REM replace this with your user name and password
REM make sure there is no space between the pwd and the >>

echo user me > getftp.dat
echo mypass>> getftp.dat

echo binary >> getftp.dat

REM replace this with the remote dir (or remove, if not required)

echo cd remoteSubDir >> getftp.dat

REM replace this with the local dir

echo lcd C:\Users\UserName\SomeLocalSubDir >> getftp.dat

REM replace this with the file name

echo get file.file >> getftp.dat
echo quit >> getftp.dat

REM replace this with the server name

ftp -n -s:getftp.dat example.com

del getftp.dat

我以前在批处理文件中使用WGET来完成此任务。 http://www.gnu.org/software/wget/

你使用什么FTP客户端软件? 它是可编写脚本的吗? 如果是这样,请创建一个脚本,用于下载文件并从批处理文件中调用此脚本。

我是用WS_FTP做的。

大多数Windows操作系统内置的命令行FTP程序都是可编写脚本的 如果您手动运行它(每行一个命令),您只需要使用您将发送的命令创建一个文本文件,然后执行它:

ftp -s:download.scr

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM