curl:从stdin传递一个命名参数 [英] curl: pass a named parameter from stdin

查看:469
本文介绍了curl:从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆