bash脚本中的curl出现错误curl:(3)在URL中发现非法字符

bash脚本中的curl出现错误curl:(3)在URL中发现非法字符,curl,Curl,我有下面的脚本 echo Getting Data from MyTotalControl Website /etc/openhab2/scripts/therm.py -s > /var/log/honeywell.log TEMPDATA="/var/log/honeywell.log" # # echo Checking Indoor Temp TEMPSTATUS=$( grep "Indoor Temperature" "$TEMPDATA" | sed -n -e 's/^.*

我有下面的脚本

echo Getting Data from MyTotalControl Website
/etc/openhab2/scripts/therm.py -s > /var/log/honeywell.log
TEMPDATA="/var/log/honeywell.log"
#
#
echo Checking Indoor Temp
TEMPSTATUS=$( grep "Indoor Temperature" "$TEMPDATA" | sed -n -e 's/^.*Indoor Temperature: //p')
curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "$TEMPSTATUS" "http://xxx.xxx.xxx.xxx:xxxxx/rest/items/IndTemp" "\n"
echo "$TEMPSTATUS"
#
#
exit 0
我得到一个错误:

Getting Data from MyTotalControl Website
Checking Indoor Temp
curl: (3) Illegal characters found in URL
28
: numeric argument required: line 39: exit: 0
它获取室内温度,但我有一个旋度错误和那个数值参数

当我在terminal中使用curl命令时

$ curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "33" "http://xxx.xxx.xxx.xxx:xxxxx/rest/items/IndTemp"
它按预期工作并更新我的项目。 我做错了什么?
提前感谢您。

在URL之后,脚本中的最后一行新行应该做什么?我想这是您的问题…尝试时没有“\n”,但问题相同。