【问题标题】:Batch script to watch for changes on FTP server用于监视 FTP 服务器上的更改的批处理脚本
【发布时间】:2013-04-20 19:13:20
【问题描述】:

我想让一个批处理脚本能够在每次在 ftp 服务器上上传新文件时侦听我的 ftp 服务器并将文件下载到我的计算机。

有什么想法吗?我使用 WinSCP。

【问题讨论】:

    标签: batch-file ftp winscp


    【解决方案1】:

    使用 WinSCP 的 /synchronize 本地开关。它将检查远程服务器并下载任何与本地目录不匹配的文件。

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

    然后您可以使用任务管理器按计划运行它或在循环中的批处理文件中使用它

    例如:

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

    将每 10 秒运行一次。

    阅读Command line options for WinSCP 了解更多信息。

    【讨论】:

    • 我看不出这怎么可能是自动的。您缺少 /defaults 开关 + 无论如何您都不能跳过同步清单窗口。
    • 好的,看起来可能只是您这边的语法错误;正如我所见,您已经从synchronize 脚本命令语法中复制了同步参数,而不是/synchronize 命令行参数。所以你可能走在了正确的轨道上。无论如何,请参阅我的答案以了解正确的语法。
    【解决方案2】:

    您可以将WinSCP scripting 与其synchronize command 一起使用:

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

    在 Windows XP 和更早版本上,使用 ping -n 10 127.0.0.1 而不是 timeout 10


    另见:

    【讨论】:

      猜你喜欢
      • 2017-03-25
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多