Command prompt having trouble escaping quotes and braces

Deadly 提交于 2019-12-30 00:27:08

问题


I am trying to execute the following line in command prompt:

curl -X POST -d '{ "method" : "account_info", "params" : [ { "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"} ] }' http://s1.ripple.com:51234

However, I get the following:

curl: (6) Could not resolve host: method
curl: (7) Failed connect to :80; No error
curl: (6) Could not resolve host: account_info,
curl: (6) Could not resolve host: params
curl: (7) Failed connect to :80; No error
curl: (3) [globbing] illegal character in range specification at pos 2
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: account
curl: (7) Failed connect to :80; No error
curl: (3) [globbing] unmatched close brace/bracket at pos 35
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (3) [globbing] unmatched close brace/bracket at pos 1
unable to parse request

I am on windows, and the error has to do with quotes, braces, and globbing. I tried escaping quotes by preceding them with a backslash, with no luck.

I am sure I just need to escape the right stuff, in the right way, but am having a hard time doing it. Some help would be highly appreciated.


回答1:


Try this:

curl -X POST -d "{ \"method\" : \"account_info\", \"params\" : [ { \"account\" : \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\"} ] }" http://s1.ripple.com:51234



回答2:


You can use curl -g to turn off globbing:

curl -g -X POST -d '{ "method" : "account_info", "params" : [ { "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"} ] }' http://s1.ripple.com:51234

Easier than escaping all those brackets.




回答3:


Try the basic one to post something.

curl -X POST --data '{"username":"username", "password":"password"}' --header "Content-Type:application/json" http://127.0.0.1:8000/your_url/



回答4:


In above responses, it is important to note that datas are specified in JSON format, which should require to specify --header as @Alok answer.

It is also possible to define it in "url" format like this:

curl -X POST --data "method=account_info&params=[…]" http://s1.ripple.com:51234

and avoid to specify --header "Content-Type…"



来源:https://stackoverflow.com/questions/17560858/command-prompt-having-trouble-escaping-quotes-and-braces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!