CMD / Powershell:不与cURL一起使用的命令。 Cygwin的作品

时间:2014-01-13 20:09:38

标签: windows powershell curl cmd cygwin

我正在尝试将本教程用于CMD和Windows Powershell(Windows 7 64):http://www.elasticsearchtutorial.com/elasticsearch-in-5-minutes.html

第一个命令在CMD中不起作用:

curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'

我收到以下错误消息:

curl: (1) Protocol 'http not supported or disabled in libcurl
curl: (6) Could not resolve host: name
curl: (7) Failed to connect to  port 80: Connection refused
curl: (6) Could not resolve host: Dilbert Brown
curl: (3) [globbing] unmatched close brace/bracket in column 1

在Windows Powershell中,我得到:

{"error":"MapperParsingException[failed to parse]; nested: JsonParseException[Unrecognized token 'Dilbert': was expecting ('true', 'false' or 'null')\n at [Source: [B@132b73b; line: 1, column: 33]]; ","status":400}curl: (3) [globbing] unmatched close brace/bracket in column 7

同样的命令在Cygwin中没有任何问题。我如何编写命令使其在CMD和Windows Powershell中工作?

1 个答案:

答案 0 :(得分:2)

在PowerShell中,从解析角度正确调用该命令。

在cmd.exe中,单引号无效。您需要使用双引号来包围值。

curl -XPUT "http://localhost:9200/blog/user/dilbert" -d "{ \"name\" : \"Dilbert Brown\" }"