curl:从stdin传递一个命名参数 [英] curl: pass a named parameter from stdin
问题描述
我有一个Web服务,希望一些参数。我想通过stdin传递这些参数之一(名为数据)curl。
我尝试了
I have a web service that expects some parameters. I want to pass one of these parameters (named "data") to curl via stdin. I tried
echo -n "some data" | curl -d x="foo" -d y="bar" -d data=@- "http://somewhere"
这不起作用,因为数据的值是@ - 而不是一些数据。
which doesn't work, as the value of data then is "@-" instead of "some data".
@ in curl将stdin的输入与一个特定的参数相关联?
Is it possible to use the @ in curl to associate the input from stdin with a specific parameter?
edit:我的目标是链接多个Web服务,所以我传递的数据将是另一个输出curl call。
edit: My goal is to chain multiples web services so the data I pass will be the output of another curl call.
推荐答案
这不可能吗?
curl -d x="foo" -d y="bar" -d data="@some data" "http://somewhere"
或
curl -d x="foo" -d y="bar" -d data="@$(echo "some data")" "http://somewhere"
$ b b
echosome data
可以是另一个命令或文件输入: $(< somefile)
。
echo "some data"
can be another command or file input: $(<somefile)
.
这篇关于curl:从stdin传递一个命名参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!