我正在开发一个脚本,与其他脚本一起使用的脚本可以通过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

最佳答案

Stackoverflow的语法highlite告诉我们这里有问题

ResultString+=`curl "http://192.168.1.141:8086/json.htm?type=devices&rid=8" 2>/dev/null` | jq -r .result[].Data`

这里是反勾号
null`

关于linux - 意外的EOF,缺少报价或反引号?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25521036/

10-09 04:45