3
您好我想在shell腳本中使用curl,如下所示,但我無法用CURL中的變量$ line替換。請建議在shell腳本中使用curl來代替變量
while read line
do
echo "allowing mac $line"
curl -X POST -d '{"src-mac": "$line"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"dst-mac": "$line"}' http://localhost:8080/wm/firewall/rules/json
done < /home/floodlight/allowedmacs
或交換雙/單引號:''{'src-mac':'$ line'}「' –
@glennjackman - nope。雖然在JavaScript代碼中有效的文字,這是不合法的[JSON](http://www.json.org/),它需要雙引號字符串。 –