作为一个单独的工具,它工作得很好:
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输出,然后处理它?
当前回答
如果你正在尝试类似source <(curl -sS $url)这样的东西,并得到(23)Failed writing body错误,这是因为在bash 3.2 (macOS的默认)中,源进程替换不起作用。
相反,您可以使用这个解决方案。
source /dev/stdin <<<"$( curl -sS $url )"
其他回答
因为我自己的打字错误,我也有同样的问题:
# 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 $?
就我而言,我在做: Curl <blabla> | jq | grep <blibli>
用jq。它工作:curl <blabla> | jq。| grep <blibli>
对我来说,这是许可问题。Docker运行是使用用户配置文件调用的,但root是容器内的用户。解决方案是让curl写入/tmp,因为它对所有用户都有写权限,而不仅仅是根用户。
我使用了-o选项。
- o / tmp / file_to_download
I was getting curl:(23)写作体不及格。后来我注意到我没有足够的空间通过curl下载rpm包,这就是我得到问题的原因。我腾出了一些空间和问题来解决。
用sudo尝试命令对我有用。例如:
sudo curl -O -k 'https url here'
注意:-O(这是大写o,不是零)& -k https url。