我试图使用karate.fork在空手道中运行以下命令
ssh -o ProxyCommand="ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost" -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -o PasswordAuthentication=no root@finaldest echo test我将其分解为一个数组,以便像这样传递给karate.fork:
[
ssh,
-o,
ProxyCommand="ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost",
-i,
~/.ssh/id_rsa,
-o,
StrictHostKeyChecking=no,
-o,
PasswordAuthentication=no,
root@finaldest,
echo test
]然后按如下方式运行该命令:
* karate.fork(args),其中args是上面提到的数组
当我将它粘贴到终端并手动运行它时,该命令可以工作,但是当使用karate.fork运行时,我得到
zsh:1: no such file or directory: ssh -W finaldest:22 -I ~/.ssh/id_rsa root@myjumphost
kex_exchange_identification: Connection closed by remote host 我尝试在"之前添加几个反斜杠,但是没有多少反斜杠可以解决这个问题。我想我误解了karate.fork在运行命令时所做的事情,是否存在对给定输入的内部解析或操作?当我使用useShell: true时,我能够让这个命令正常工作,但是这个选项破坏了我的其他测试,所以我真的很想避免它。
发布于 2022-10-05 16:47:40
我不得不删除双引号,看起来他们对karate.fork的操作不太好,而且命令仍然没有运行
[
ssh,
-o,
ProxyCommand=ssh -W %h:%p -i ~/.ssh/id_rsa root@myjumphost,
-i,
~/.ssh/id_rsa,
-o,
StrictHostKeyChecking=no,
-o,
PasswordAuthentication=no,
root@finaldest,
echo test
]https://stackoverflow.com/questions/73941264
复制相似问题