WinSCP script not executing in batch file

前端 未结 2 1395
野趣味
野趣味 2021-01-14 06:24

I have a script that is executing perfectly on command prompt. If I copy and paste the script directly to the command window then it is working fine, but when save it like

2条回答
  •  一个人的身影
    2021-01-14 07:02

    Think of the command prompt as a sequence of inputs to prompts, while a batch script is a sequence of commands to execute. The batch script does not know that the get, close, and exit statements are actually inputs to the winscp prompts but is waiting till winscp finishes to run them individually.

    You can try piping the input to winscp in a batch file like so:

    cd \program files\winscp\ 
    (
        echo.option batch abort
        echo.option confirm off
        echo.get /*.csv C:\HennTest\VCS\
        echo.close
        echo.exit
    ) | winscp.com /command "open HennTest:Nate82@data.test.com" /privatekey=C:\HennTest\VCS\HennTest_key_putty.ppk
    

    Note: This piping method may not work depending on how the program implements the input buffer.

提交回复
热议问题