我正在处理与其他脚本一起使用的脚本,可以通过Telegram发送系统或其他通知,该脚本从domoticz提取数据。
我确定我在某个地方错过了引用或反复,但我希望有人能够阅读小脚本,并提供一双新的眼睛,看看我搞砸了哪里:
#!/bin/bash
# Settings
TelegramSendMsg="/opt/telegram/scripts/generic/telegram.sh"
TmpFileName="/opt/telegram/scripts/tmp/SystemStatus.txt"
SendMsgTo=$1
#Send sensor values with telegram
##############################################################################
ResultString+="CPU Usage: "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=8" 2>/dev/null` | jq -r .result[].Data`
ResultString+="\n"
ResultString+="Memory Usage: "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=1" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=6" 2>/dev/null | jq -r .result[].Name`
ResultString+=" : "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=6" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=4" 2>/dev/null | jq -r .result[].Name`
ResultString+=" : "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=4" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=5" 2>/dev/null | jq -r .result[].Name`
ResultString+=" : "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=5" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=3" 2>/dev/null | jq -r .result[].Name`
ResultString+=" : "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=3" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=2" 2>/dev/null | jq -r .result[].Name`
ResultString+=" : "
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=2" 2>/dev/null | jq -r .result[].Data`
ResultString+="\n"
##############################################################################
echo -e $ResultString > $TmpFileName
$TelegramSendMsg send_text $SendMsgTo $TmpFileName
答案 0 :(得分:2)
Stackoverflow的语法highlite告诉我这里有问题
ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=8" 2>/dev/null` | jq -r .result[].Data`
这是反击
null`
答案 1 :(得分:0)
您的问题似乎是第11行上的null旁边的刻度