Curl 在节点本身上运行良好:
[ec2-user@smokebase1 ~]$ curl -s -I --retry 3 --header 'Host: smoke-base.dev-test.com' localhost:8080/test/api/search?where=where%20%2Fxml%2Fitem%2Fcategory%20is%20not%20%27dog%25%27 | grep "HTTP/1.1 200 OK" | wc -l
1
[ec2-user@smokebase1 ~]$ exit
logout
Connection to 10.4.11.14 closed.
但使用 ssh 命令却没有给出正确的结果
[vsha@ip-10-4-11-25 ~]$ ssh [email protected] 'curl -s -I --retry 3 --header 'Host: smoke-base.dev-test.com' localhost:8080/test/search?where=where%20%2Fxml%2Fitem%2Fcategory%20is%20not%20%27dog%25%27 | grep "HTTP/1.1 200 OK" | wc -l'
0
答案1
您的问题几乎肯定与引用有关。通过尝试放置'
整个 ssh 命令行,它们将与 curl 命令中已有的命令行相匹配,并产生意外结果。
您可以尝试更改curl 命令中的'
for ,然后将整个 ssh 命令包装在"
'