作为一个单独的工具,它工作得很好:
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输出,然后处理它?
当前回答
我在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 -
其他回答
对于完整性和将来的搜索:
这取决于cURL如何管理缓冲区,缓冲区使用-N选项禁用输出流。
例子: curl -s -N "URL" | grep -q欢迎
我在做的时候也遇到了同样的问题:
curl - l https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add -
上面的查询需要使用根权限执行。
用下面的方法解决了这个问题:
curl - l https://packagecloud.io/golang-migrate/migrate/gpgkey | sudo apt-key add -
如果在curl之前编写sudo,则会得到Failed writing body错误。
我在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 $?
我得到这个错误试图使用jq时,我没有安装jq。所以…如果您尝试使用jq,请确保已安装jq。