-
Notifications
You must be signed in to change notification settings - Fork 5
/
temper_test.sh
executable file
·37 lines (30 loc) · 997 Bytes
/
temper_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# redirect stdout and stderr to logfile
rm /home/hivetool/hivetool.log
exec >>/home/hivetool/hivetool.log 2>&1
HOST=`hostname`
DATE=`date +"%Y/%m/%d %H:%M"`
COUNTER=0
while [[ $COUNTER -lt 10 && $DATA_GOOD -eq 0 ]]; do
TEMPerHUM=`/usr/local/bin/tempered /dev/hidraw1`
if [[ -n $TEMPerHUM ]]
then
HUMIDITY=`echo $TEMPerHUM | grep -o "[0-9]*\.[0-9]\%" | grep -o "[0-9]*\.[0-9]"`
TEMP=`echo $TEMPerHUM | grep -o "temperature \-*[0-9]*\.[0-9]" | grep -o "\-*[0-9]*\.[0-9]"`
# if [[ -n "$TEMP" && -n "$HUMIDITY" ]]
if [[ $TEMP -eq 0 && $HUMIDITY -eq 0 ]]
then
DATA_GOOD=1
fi
fi
let COUNTER=COUNTER+1
done
echo $COUNTER $TEMP $HUMIDITY
if [[ $COUNTER -gt 9 ]]
then
echo "$DATE ERROR reading /dev/hidraw1" >> error.log
fi
if [[ $COUNTER -lt 10 && $COUNTER -gt 1 ]]
then
echo "$DATE WARNING reading /dev/hidraw1: retried $COUNTER" >> error.log
fi