作为一个单独的工具,它工作得很好:
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输出,然后处理它?
当前回答
另一种可能是,如果使用-o(输出文件)选项,目标目录不存在。
如。如果你有-o /tmp/download/abc.txt且/tmp/download不存在。
因此,确保任何需要的目录都是预先创建/存在的,使用——create-dirs选项,必要时使用-o
其他回答
对于完整性和将来的搜索:
这取决于cURL如何管理缓冲区,缓冲区使用-N选项禁用输出流。
例子: curl -s -N "URL" | grep -q欢迎
用sudo尝试命令对我有用。例如:
sudo curl -O -k 'https url here'
注意:-O(这是大写o,不是零)& -k https url。
你可以这样做,而不是使用-o选项:
Curl [url] >[文件]
就我而言,我在做: Curl <blabla> | jq | grep <blibli>
用jq。它工作:curl <blabla> | jq。| grep <blibli>
我在做的时候也遇到了同样的问题:
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错误。