作为一个单独的工具,它工作得很好:
curl "someURL"
curl -o - "someURL"
但这在流水线上行不通:
curl "someURL" | tr -d '\n'
curl -o - "someURL" | tr -d '\n'
它返回:
(23) Failed writing body
管道cURL输出的问题是什么?如何缓冲整个cURL输出,然后处理它?
作为一个单独的工具,它工作得很好:
curl "someURL"
curl -o - "someURL"
但这在流水线上行不通:
curl "someURL" | tr -d '\n'
curl -o - "someURL" | tr -d '\n'
它返回:
(23) Failed writing body
管道cURL输出的问题是什么?如何缓冲整个cURL输出,然后处理它?
当前回答
就我而言,我在做: Curl <blabla> | jq | grep <blibli>
用jq。它工作:curl <blabla> | jq。| grep <blibli>
其他回答
在我的情况下,服务器耗尽了磁盘空间。
用df -k检查它。
当我尝试两次通过tac进行管道处理时,我被提醒磁盘空间不足,如另一个答案:https://stackoverflow.com/a/28879552/336694中所描述的那样。它向我显示了错误消息写错误:设备上没有剩余空间。
我在ubuntu上安装清漆缓存时遇到了这个错误信息。谷歌搜索让我在这里的错误(23)失败的写作主体,因此张贴一个解决方案,为我工作。
在以根curl - l https://packagecloud.io/varnishcache/varnish5/gpgkey | apt-key add -的身份运行命令时遇到此错误
解决方案是以非根用户身份运行apt-key add
curl -L https://packagecloud.io/varnishcache/varnish5/gpgkey | apt-key add -
因为我自己的打字错误,我也有同样的问题:
# fails because of reasons mentioned above
curl -I -fail https://www.google.com | echo $?
curl: (23) Failed writing body
# success
curl -I -fail https://www.google.com || echo $?
对我来说,这是许可问题。Docker运行是使用用户配置文件调用的,但root是容器内的用户。解决方案是让curl写入/tmp,因为它对所有用户都有写权限,而不仅仅是根用户。
我使用了-o选项。
- o / tmp / file_to_download
所以这是编码的问题。Iconv解决了这个问题
curl 'http://www.multitran.ru/c/m.exe?CL=1&s=hello&l1=1' | iconv -f windows-1251 | tr -dc '[:print:]' | ...