Moin,
Ich hab da einen komischen Fehler ich hab ein script welches mir Temperaturdaten ausliest, allerdings wen ich dieses ausgaben in eine Datei umleite wird immer eine weitere Zeile eingefügt mit einem c
FrendlyARM scrips # sh tnc75remote.sh
25.5
FrendlyARM scrips # sh /var/www/htdocs/scrips/tnc75remote.sh > /var/www/htdocs/data/flur-temp.tmp
FrendlyARM scrips # cat /var/www/htdocs/data/flur-temp.tmp
25.5
c
FrendlyARM scrips #
|
Quellcode
|
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
|
#!/bin/bash
# by K.Jacobs / http://www.grautier.com / CC-by-NC-SA
## Temperatur I2C Sensor TNC75 over wget##
wget -q http://192.168.0.201/temp.txt -O /var/www/htdocs/data/flur-temp.tmp
LSB=$(cat /var/www/htdocs/data/flur-temp.tmp | awk -F "0x" '{print $2}')
MSB=$(echo "$LSB" | cut -c1-2) # MSB = MSB
LSB=$(echo "$LSB" | cut -c3-4) # LSB = LSB
LSB=$(echo "$LSB" | tr '[a-z]' '[A-Z]') # In grossbuchstaben wandeln für BC
LSB=$(echo "ibase=16; $LSB" | bc) # umwandeln HEX->DEC
if [ "$MSB" = "80" ]; then # MSB = 80 dann 0,5 anfügen
LSB=$(echo "scale=5; $LSB + 0.5" | bc) # .5 anfügen
fi
LSB=$(echo "scale=5; $LSB - 3" | bc) # Sensor Calibriren -3C
if [ "$LSB" = "-3" ]; then # LSB = -3 dann var L�schen
LSB=$(echo "") # bei Datenfehler nichts Anzeigen
fi
echo $LSB
exit 0
|