我正在使用BLS API处理项目。
参考:http://www.bls.gov/developers/api_unix.htmBash Script_将从读命令读取的变量插入到命令中
我现在的脚本如下:
declare id=""
echo -n "Enter id: "
read id
echo -n "enter startyear: "
read startyear
echo -n "enter endyear: "
read endyear
curl -i -X POST -H 'Content-Type: application/json' -d '{"seriesid": ["$id"], "startyear":'$startyear' , "endyear":'$endyear'}' http://api.bls.gov/publicAPI/v2/timeseries/data/
我已经编辑,并把在ID用手像参考网页和工作。我似乎无法从输入中读取$ id并将其插入到curl命令中。任何援助与此非常感谢你。
EDIT1:
我更新的代码,改变了报价为{} -d选项,以双引号和相同的错误仍然存在。
EDIT2:
更新与在评论中提供的代码的文件后,我收到一个:
Warning: You can only select one HTTP request!
当我运行它
。
变量'$ id'没有被扩大,因为它是单引号内。 – Phylogenesis 2015-03-13 15:44:17
我刚更新了它,但仍然遇到同样的问题。 – 2015-03-13 15:55:05
您的第二次编辑建议您正在执行'-I'而不是'-i'。 – Phylogenesis 2015-03-13 16:09:30