gpt4 book ai didi

Linux:代码中的错误输出

转载 作者:太空宇宙 更新时间:2023-11-04 12:55:39 24 4
gpt4 key购买 nike

我有下面的代码,不幸的是它给出了以下结果。我不明白的事情。有谁知道我做错了什么?该代码用于将数据从 Domoticz(在 Linux 上运行的开源 Domotica 系统)传输。

cat: $: No such file or directory
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: SID=none; path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT

代码:

#!/bin/bash

# Domoticz server
SERVER="192.168.0.xxx:8080"

# DHT IDX
# le numéro de l IDX dans la liste des peripheriques
DHTIDX="25"
#DHTPIN
# LE GPIO ou est connecte le DHT11
DHTPIN="27"

# si vous avez un DHT22 modifiez plus bas sur la ligne Adafruit_DHT 11 par Adafruit_DHT 22
# TMPFILE : chemin pour fichier temporaire a placer dans le RAMDRIVE pour eviter les
# ecritures sur la SD card
# sinon chemin ou sera ecrit le fichier contenant les temperature
# /tmp/temper.txt est un bon choix si pas de RAMDRIVE installe
# consultez www.easydomoticz.com pour tout savoir

TMPFILE="/var/tmp/temper.txt"
# modif de patrick du 08/03/15 pour interroger que 5 fois maxi
cpt=0
while [ $cpt -lt 6 ]
do
TEMP=""
sleep 5
sudo nice -20 ./Adafruit_Python_DHT/examples/AdafruitDHT.py 22 $DHTPIN > $TMPFILE
TEMP=$(cat $TMPFILE|grep Temp |awk '{print $3}')
if [ $TEMP ]
then
TEMP=$(cat $TMPFILE|grep Temp |awk '{print $3}')
HUM=$(cat $ $TMPFILE |grep Temp |awk '{print $7}')
#echo $TEMP
#echo $HUM
# Send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;2"
TEMP=""
HUM=""
rm $TMPFILE
exit 0
fi
#echo $cpt
cpt=$(($cpt+1))
done
exit 1

非常感谢您!

最佳答案

看起来你在这一行中多了一个$

HUM=$(cat $ $TMPFILE |grep Temp |awk '{print $7}')

尝试将其更改为

HUM=$(cat $TMPFILE |grep Temp |awk '{print $7}')

看看它是否有效。

关于Linux:代码中的错误输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35811127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com