English 中文(简体)
FTP服务器向当地名录提供文档?
原标题:Copy files from FTP server to local directory?

I want to create a batch file in Windows Server, including the following functions:

  • Connection to a FTP server
  • Copying the files from there (directory called "out") to a local directory
  • if success, then deleting the files from the FTP server
  • repeating those steps every 15 minutes

我没有做这么多有批量的文件,如果你能够帮助我的话,那将是巨大的。 我知道有<代码>ftp的指挥,我知道如何连接(ftp open),但不幸的是,我不知道如何每15分钟从那里复制这些档案。

感谢你们的帮助!

最佳回答

To program ftp from a batch file, see http://support.microsoft.com/kb/96269。 你们需要这样说。

ftp -i -s:ftpcommands.txt

倾角 t望这样的情况:

open ftp.myftpsite.com
username
password
bin
cd out
mget *
del *
bye

每次15分钟,请参看其他答复(at或突击表)。

(-i para amount is to rec off interactive riseing - the other way to do this is to addition a prompt offtor to the presss text file before the mget/code>. 否则,mget将停止,请您在查阅每份文件之前确认。 [Thanks to Adriano for pointing this out!]

问题回答

接受@AAT的回答,建议使用Windows Building-in ftp.exe的指挥线客户。 虽然这能够奏效,但更经常是会赢得失败,因为这一客户只支持快车轮车的运行模式,而这种方式与今天的无休无止的防火墙和NAT没有作用。 它也不支持加密的FTPS(FTP优先于TLS/SSL)。

如果存在上述问题,你需要使用第三党的受款人。 其中大多数都支持被动模式和加密。


例如,可在WinSCP FTP的客户上使用下列批量文档(.bat):

WinSCP.com /command ^
    "open ftp://username:password@ftp.example.com/" ^
    "get /out/* c:localpath" ^
    "exit"

如果有的话,则有<代码>ftp.exe。 文字,有,将其改为WinSCP script


关于时间安排部分,见,指向FTP服务器发送时间。


(WinSCP的作者)

仅使用1 (1) .bat卷宗。 在临时档案中设立财务审查处,然后删除临时档案。

SET "FTPFILE=%TEMP%myftpscript_%RANDOM%.txt"

ECHO>>"%FTPFILE%" open ftp.myftpsite.com
ECHO>>"%FTPFILE%" username
ECHO>>"%FTPFILE%" password
ECHO>>"%FTPFILE%" bin
ECHO>>"%FTPFILE%" cd out
ECHO>>"%FTPFILE%" mget *
ECHO>>"%FTPFILE%" del *
ECHO>>"%FTPFILE%" bye

ftp -i -s:"%FTPFILE%"

IF EXIST "%FTPFILE%" (DEL "%FTPFILE%")

EXIT /B 0




相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签