将文件从 FTP 服务器复制到本地目录? [英] Copy files from FTP server to local directory?
问题描述
我想在Windows Server中创建一个批处理文件,包括以下功能:
I want to create a batch file in Windows Server, including the following functions:
- 连接到 FTP 服务器
- 将文件从那里(名为out"的目录)复制到本地目录
- 如果成功,则从 FTP 服务器中删除文件
- 每 15 分钟重复这些步骤
到目前为止我还没有对批处理文件做过那么多,所以如果你能帮助我就太好了.我知道有 ftp
命令,我知道如何连接(ftp open
),但不幸的是我不知道如何每 15 分钟从那里复制这些文件.
I haven't done that much with batch files so far, so it would be great if you could help me. I know there is the ftp
command, and I know how to connect (ftp open
), but unfortunately I don't know how to copy those files from there every 15 minutes.
非常感谢您的帮助!
推荐答案
要从批处理文件编写 ftp,请参阅 http://support.microsoft.com/kb/96269.你需要像这样调用ftp
To program ftp from a batch file, see http://support.microsoft.com/kb/96269. You need to call ftp like this
ftp -i -s:ftpcommands.txt
ftpcommands.txt 看起来像这样:
where ftpcommands.txt looks something like this:
open ftp.myftpsite.com
username
password
bin
cd out
mget *
del *
bye
要每 15 分钟运行一次,请参阅其他回复(at
或命令调度程序).
For running this every 15 minutes, see other replies (at
or Command Scheduler).
(-i
参数是关闭交互式提示 - 另一种方法是添加一个 prompt off
命令到mget
之前的命令文本文件.没有这个,mget
会在获取每个文件之前停止并要求您确认.[感谢 Adriano 指出这一点!])
(The -i
parameter is to turn off interactive prompting - the other way to do this is to add a prompt off
command to the commands text file before the mget
. Without this, mget
will stop and ask you to confirm before getting each file. [Thanks to Adriano for pointing this out!])
这篇关于将文件从 FTP 服务器复制到本地目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!