将脚本 commands/input 传递到打开的 WinSCP shell
Pass script commands/input to opened WinSCP shell
我正在尝试使用 WinSCP.com
自动执行文件传输,这有点像 shell,有它的命令和参数。
但是自动脚本将是来自 .cmd
或 .bat
文件的 运行。
因此,这是我的自动化脚本:
C:
CD "C:\Program Files (x86)\WinSCP"
CALL WinSCP.com
REM This opens a
REM winscp>
REM shell or process
REM now theoretically I should be able to run the WinSCP commands
REM but they are not being piped into the winscp shell
open mypassword | myuser@myserver
REM the last command is not being executed.
REM Instead the script hangs on the newly opened WinSCP shell.
REM There are other winscp commands such as put <file> <path>
我的问题是如何告诉 WinSCP 进程从批处理脚本文件中获取命令 open mypassword | myuser@myserver
?
哦还有额外的:我想在最后杀了winscp
process\shell。我在这里不知道正确的术语。是进程还是shell?
如果你想在批处理文件中使用 WinSCP 命令(而不是在使用 /script
开关引用的单独脚本文件中),你可以使用 WinSCP /command
switch。
winscp.com /ini=nul /command ^
"open sftp://myuser:mypassword@myserver/" ^
"..."
"exit"
你可以WinSCP GUI generate a batch file template(像上面那个)。
虽然建议使用 /command
开关,但您实际要求的是这样的:
(
echo open sftp://myuser@myserver/
echo mypassword
...
echo exit
) | winscp.com
请注意,与 /commands
相比,在某些情况下行为会有所不同,因为当在标准输入上提供命令时,WinSCP 假定交互式(人类)使用。这就是为什么你应该使用 /commands
.
我正在尝试使用 WinSCP.com
自动执行文件传输,这有点像 shell,有它的命令和参数。
但是自动脚本将是来自 .cmd
或 .bat
文件的 运行。
因此,这是我的自动化脚本:
C:
CD "C:\Program Files (x86)\WinSCP"
CALL WinSCP.com
REM This opens a
REM winscp>
REM shell or process
REM now theoretically I should be able to run the WinSCP commands
REM but they are not being piped into the winscp shell
open mypassword | myuser@myserver
REM the last command is not being executed.
REM Instead the script hangs on the newly opened WinSCP shell.
REM There are other winscp commands such as put <file> <path>
我的问题是如何告诉 WinSCP 进程从批处理脚本文件中获取命令 open mypassword | myuser@myserver
?
哦还有额外的:我想在最后杀了winscp
process\shell。我在这里不知道正确的术语。是进程还是shell?
如果你想在批处理文件中使用 WinSCP 命令(而不是在使用 /script
开关引用的单独脚本文件中),你可以使用 WinSCP /command
switch。
winscp.com /ini=nul /command ^
"open sftp://myuser:mypassword@myserver/" ^
"..."
"exit"
你可以WinSCP GUI generate a batch file template(像上面那个)。
虽然建议使用 /command
开关,但您实际要求的是这样的:
(
echo open sftp://myuser@myserver/
echo mypassword
...
echo exit
) | winscp.com
请注意,与 /commands
相比,在某些情况下行为会有所不同,因为当在标准输入上提供命令时,WinSCP 假定交互式(人类)使用。这就是为什么你应该使用 /commands
.