当管道输入头部命令时,curl会出错
发布时间:2020-12-13 23:25:29 所属栏目:Linux 来源:网络整理
导读:这很好用,没有错误: $curl -sSL https://coinbase.com/api/v1/prices/historical2014-04-27T18:19:17-07:00,430.522014-04-27T18:10:24-07:00,436.252014-04-27T17:56:57-07:00,436.14... 这会出现以下错误: $curl -sSL https://coinbase.com/api/v1/price
这很好用,没有错误:
$curl -sSL https://coinbase.com/api/v1/prices/historical 2014-04-27T18:19:17-07:00,430.52 2014-04-27T18:10:24-07:00,436.25 2014-04-27T17:56:57-07:00,436.14 ... 这会出现以下错误: $curl -sSL https://coinbase.com/api/v1/prices/historical | head -n 1 2014-04-27T18:19:17-07:00,430.52 curl: (23) Failed writing body (0 != 186) 当我管道到grep和tail时它不会失败,但是当我管道到头时(即使没有参数)也失败了. 我得到了我想要的东西,但它给出了一个错误.最后一个数字(上例中的186)每次都会改变.我刚跑了三次,得到了1650,3988和923. 我尝试用-B选项运行它.如果它有用,我在OSX 10.9上.我没有?/ .curlrc.这是curl –version的输出: curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz 这里出了什么问题? 解决方法
在卷曲完成之前,头部正在关闭管道.您可以使用-N标志禁用curl中的缓冲,从而将所有输出写入一个大块中的管道,以便head可以对整个响应进行操作:
curl -sNL https://coinbase.com/api/v1/prices/historical | head -n 1 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |