从Win7运行cUrl cmd不起作用,但是在Linux上却可以 [英] Running cUrl cmd from Win7 doesn't work, but on Linux it does

查看:278
本文介绍了从Win7运行cUrl cmd不起作用,但是在Linux上却可以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像标题说的那样.我正在从Win7向Linux盒子上的CouchDB发送一个简单的cUrl cmd,但是它不起作用.但是,如果我在Linux中运行相同的命令,它将起作用.我正在发送此:

Like the title says. I'm sending a simple cUrl cmd from Win7 to CouchDB on my Linux box, and it doesn't work. But if I run the same command in Linux, it works. I'm sending this:

curl -X POST 192.168.2.5:5984/test/testdoc -d '{"owner":{"fname":"test","lname":"ing"}}'

在Windows中,它一直给我一个错误:错误的请求,原因:无效的UTF-8 JSON". 我可以从Windows很好地运行GET命令,但似乎无法发布到CouchDB.

From windows, it keeps giving me a "error: bad request, reason:invalid UTF-8 JSON". I can run GET commands from windows just fine, I just can't seem to POST to CouchDB.

推荐答案

不幸的是,Windows Shell(cmd.exe)使用的引号不同于Mac OSX和Linux.

Unfortunately, the Windows shell (cmd.exe) uses quote marks differently from Mac OSX and Linux.

最简单的解决方法是避免单引号并使用双引号,而JSON文档中的双引号已转义:

The simplest fix is to avoid single-quotes and use double quotes, with the double-quotes in the JSON document escaped:

curl -X PUT 192.168.2.5:5984/test/testdoc -d "{\"owner\":{\"fname\":\"test\",\"lname\":\"ing\"}}"
{"ok":true,"id":"testdoc","rev":"1-299729b3cb92a371136cb7331c66644d"}

另一种选择是安装其他Shell,例如Windows版Bash: http://win-bash.sourceforge .net/.然后,您可以按照文档进行操作,并更轻松地进行自己的实验.

Another option is to install a different shell such as Bash for Windows: http://win-bash.sourceforge.net/. Then you can follow documentation and do your own experiments more easily.

这篇关于从Win7运行cUrl cmd不起作用,但是在Linux上却可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆