代码之家  ›  专栏  ›  技术社区  ›  dynamicJos

调用WinSCP检查主机上是否存在文件,是否使用批处理文件-每天运行

  •  1
  • dynamicJos  · 技术社区  · 9 年前

    with username & password arguments

    到目前为止,我能够启动WinSCP服务器,但批处理文件仍然不使用用户名和密码-它仍然在请求用户名和密码和/或提供关于太多参数的错误。

    chdir /d D:\Program Files\WinSCP\
    winscp.com 172.18.186.39 username password
    

    simple call prompting

    1 回复  |  直到 9 年前
        1
  •  2
  •   Martin Prikryl    9 年前

    你的语法一点也不像 WinSCP command-line syntax for scripting .


    Checking file existence using scripting

    @echo off
    
    set REMOTE_PATH=/home/user/test.txt
    winscp.com /command ^
        "open ftp://username:password@ftp.example.com/" ^
        "stat %REMOTE_PATH%" ^
        "exit"
    
    if %ERRORLEVEL% neq 0 goto error
    
    echo File %REMOTE_PATH% exists
    rem Do something
    exit /b 0
    
    :error
    echo Error or file %REMOTE_PATH% not exists
    exit /b 1
    

    以上示例适用于FTP协议。你没有告诉use你使用的是什么协议。如果不是FTP,则必须更改 open command 照着

    WinSCP GUI generate the open command for you


    一旦批处理文件就绪,请使用 Windows Scheduler to call it regularly .

    推荐文章