[英]How to pass argument to batch file in ssh?
I am trying to run a batch-file on remote windows machine, from macos through ssh commands.我正在尝试从macos到ssh命令在远程Windows机器上运行批处理文件。
sshpass -p 'password' ssh username@server < abc.bat
I want to send argument to my batch file.我想将参数发送到我的批处理文件。
sshpass -p 'password' ssh username@server < abc.bat variable1
I get error我得到错误
'variable1' is not recognized as an internal or external command, operable program or batch file
In my batch file I want to read this variable1
and pass it to one exe that I use as parameter.在我的批处理文件中,我想读取这个
variable1
并将它传递给我用作参数的一个 exe。
set var1=%1
xyz.exe %var1%
Can someone help.有人可以帮忙吗。
ssh username@server "abc.bat variable1"
That command will run abc.bat
and provide variable1
as the first argument.该命令将运行
abc.bat
并提供variable1
作为第一个参数。
However, be wary of chaining commands like sshpass
.但是,要警惕像
sshpass
这样的链接命令。 In the following example,在下面的例子中,
sshpass -p 'password' ssh username@server "abc.bat variable1"
will "abc.bat variable1"
be an argument of ssh
or sshpass
?? "abc.bat variable1"
会是ssh
或sshpass
的参数吗?? I do not know, I do not use sshpass
, but it is a confusion that can occur.我不知道,我不使用
sshpass
,但这是可能发生的混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.