如何从批处理文件执行WinSCP命令

时间:2018-07-17 14:32:15

标签: batch-file command-line sftp winscp

我想知道是否有一种方法可以从批处理文件运行 java.io.IOException: Cannot run program "npm" (in directory "/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/target/angular5/tourism"): error=2, No such file or directory 之类的WinSCP命令,而不必在WinSCP打开后输入命令。

这就是我想发生的事情:

  1. 我创建一个打开WinSCP命令行的批处理文件(例如 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> )。
  2. 我在open sftp...中插入WinSCP命令(demo.batopenget等)。
  3. 批处理文件put打开WinSCP命令行并自动执行命令(demo.batdemo.bat等)。

1 个答案:

答案 0 :(得分:1)

使用/command or /script command-line switches

有一个guide to automating file transfers to SFTP server with WinSCP

使用/command开关的简单批处理文件如下:

WinSCP.com ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://username:password@example.com/" ^
    "put C:\local\path\file.txt /remote/path/" ^
    "exit"

WinSCP GUI实际上甚至可以generate the batch file for you

enter image description here