我在git bash终端(不是Windows命令行或mac的终端)中运行以下命令。
ssh username@code.companyname.com -p 12356 gerrit query --format=JSON --current-patch-set --files change: 878545
当我在git bash中运行它时会生成一个JSON输出。我正在尝试使用以下命令在Python文件中执行相同的操作:
import subprocess
result = subprocess.run(
[
"ssh",
"-c",
"aes128-cbc", #adds necessary ciphers
"username@code.companyname.com",
"-p",
"12356",
"gerrit",
"query",
"--format=JSON",
"--current-patch-set",
"--files",
"change: ",
"878545",
], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True
)
result_process = result.stdout.decode("utf-8")
print(result_process)
但这产生了错误:'ssh' is not recognized as internal or external command, operable program or batch file.
ssh
在命令行中工作。