在远程计算机上执行卷曲

时间:2018-06-01 09:43:31

标签: linux curl ssh

我在系统上本地执行curl命令,它工作正常,

curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm

我想通过ssh在远程计算机上执行此操作,这样做,我得到连接拒绝。

ssh root@x.x.x.x $(curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed connect to localhost:9000; Connection refused
Last login: Fri Jun  1 09:38:01 2018 from 10.1.35.28

卷曲命令执行导致远程主机错误

# ssh root@x.x.x.x curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: application; Unknown error
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: ipAddress; Unknown error
{"timestamp":1527844486340,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"100   291    0   251  100    40   2533    403 --:--:-- --:--:-- --:--:--  2533aintenance/vm"}

======================

a='curl -H "Content-Type: application/json" -k -X POST -d '{"a":"value","ipAddress":"${variable}"}' https://localhost:9000/netconf/vm/maintenance/vm'
# ssh root@x.x.x.x ${a}
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: ipAddress:10.1.35.38; Unknown error
{"timestamp":1527847037512,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read document: Unrecognized token 'maintainanceMode': was expecting ('true', 'false' or 'null')\n at [Source: java.io.PushbackInputStream@339ead3; line: 1, column: 18]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'maintainanceMode': was expecting ('true', 'false' o100   633    0   593  100    40   5847    394 --:--:-- --:--:-- --:--:--  584718]","path":"/netconf/vnfm/maintenance/vm"}

任何帮助将不胜感激。

0 个答案:

没有答案