Batch script to watch for changes on FTP server

↘锁芯ラ 提交于 2020-01-01 19:27:17

问题


I want to make a batch script able to listen to my ftp server and download files to my computer every time a new file is uploaded on the ftp server.

Any ideas? I use WinSCP.


回答1:


You can use WinSCP scripting with its synchronize command:

:Loop
winscp.com /command ^
    "option batch abort" ^
    "open <session>" ^
    "synchronize local <local directory> <remote directory>" ^
    "exit"
timeout 10
goto :Loop

On Windows XP and older, use ping -n 10 127.0.0.1 instead of timeout 10.




回答2:


Use the /synchronize local switch of WinSCP. It will check the remote server and download any files that don't match a local directory.

 winscp.exe [session] /synchronize local [ <local directory> [ <remote directory> ] ]

Then you can use task manager to run it on a schedule or use it in a batch file in a loop

ex:

 :Loop
 winscp.exe [session] /synchronize local [ <local directory> [ <remote directory> ] ]
 ping -n 10 127.0.0.1
 goto :Loop

will run it every 10 seconds.

Read the Command line options for WinSCP for more.



来源:https://stackoverflow.com/questions/16239371/batch-script-to-watch-for-changes-on-ftp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!