我需要从服务中GET
数据。我正在向它传递一堆it。
in存储在用逗号分隔的文件中
示例: cat id_file
1,2,3,4,5,6,7,8,9,10,.....10000.
文件中有数千个ids。
在我的shell脚本中,我使用
id_list=$(cat id_file)
curl -H "Authorization: Bearer $token" -X GET "http://prk.xyx.com/tpt/abc/v2/dce_info?Id=$id_list&mpId=0" > op_data.json
curl命令失败,并显示错误"/usr/bin/curl: Argument list too long".
现在,在curl POST
中,我们可以指定@filename
。我们能为get请求做点什么吗?
发布于 2016-11-18 15:06:26
您可以选择从“配置文件”读取所有选项和URL,而不是使用-K从命令行读取,这将完全消除长度限制。如果需要,您还可以使“配置文件”从stdin中读取,因此在编写脚本时,实际上不需要为此创建临时文件。
另请参阅自由卷曲一书中的config file部分。
示例
使用-K使用echo将参数传递给curl:
echo '-H "Authorization: Bearer $token"' | curl -K- "http://prk.xyx.com/tpt/abc/v2/dce_info?Id=$id_list&mpId=0"
或者,如果您将命令行选项存储在文件中:
curl -K arguments "http://prk.xyx.com/tpt/abc/v2/dce_info?Id=$id_list&mpId=0"
https://stackoverflow.com/questions/40670386
复制相似问题