Call WinSCP to check if files on a host exist or not using a batch file - to run everyday

前端 未结 1 1772
[愿得一人]
[愿得一人] 2021-01-16 14:42

\"with

I am trying to automate a call to a remote server using WinSCP which

相关标签:
1条回答
  • 2021-01-16 14:58

    Your syntax does not even remotely resemble WinSCP command-line syntax for scripting.


    See WinSCP article on 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
    

    The above example is for FTP protocol. You didn't tell use what protocol are you using. If not FTP, you have to change the open command accordingly.

    You can have WinSCP GUI generate the open command for you.


    Once you have the batch file ready, use Windows Scheduler to call it regularly.

    0 讨论(0)
提交回复
热议问题