简体   繁体   English

如何在ssh中将参数传递给批处理文件?

[英]How to pass argument to batch file in ssh?

I am trying to run a on remote machine, from through commands.我正在尝试从命令在远程机器上运行

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"会是sshsshpass的参数吗?? 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.

相关问题 无法将参数从批处理文件传递到python文件 - Unable to pass argument from batch file to python file 批量处理中,如何传递我右键单击的元素的文件路径作为参数? - In batch, how can i pass the file path of the element i right clicked as an argument? 如何将VBScript生成的参数传递给已经打开的批处理文件? - How to pass a VBScript-generated argument to an already-open batch file? 我可以直接将批处理文件的内容作为参数传递,而不是将其保存在批处理文件中并传递文件本身吗? - Can i pass the content of the batch file directly as argument instead of saving it in a batch file and passing the file itself? 通过 SSH 连接到 Linux 的 BATCH 文件。 如何? - BATCH file to connect to Linux via SSH. How? 如何在后台启动批处理文件中运行 ssh 反向隧道? - how to run a ssh reverse tunnel in a startup batch file in background? 如何将转义双引号传递给批处理文件 - How to pass escaped double quote to batch file 如何在批处理文件中传递用户输入? - How to pass the user input in batch file? 如何将Maven配置文件名称传递给批处理文件? - How to pass the Maven profile name to batch file? 如何使用ftp将变量传递到批处理文件的%0部分? - How to pass a variable into %0 part of batch file with ftp?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM