First sorry for this basic question. But i´m not a programmer and need some help.
I have a command that give me the temperature of a sensor.
Example:
root@machine:~ $ snmpwalk 172.69.4.25 -v 2c -c rocommunity .1.3.6.1.3.1.1.4 iso.3.6.1.3.1.1.4.1.2.5.116.101.109.112.49.1 = STRING: "31625" And a small basic bashscript that give me only the value of the string.
#!/bin/bash SLAVE="/sys/devices/w1_bus_master1/28-80000007e290/w1_slave" OUTPUT=$(/bin/cat $SLAVE | /usr/bin/awk -F 't=' ' { printf $2 } ') echo $OUTPUT w1_slave file is as below
25 01 55 00 7f ff 0c 0c 08 : crc=08 YES 25 01 55 00 7f ff 0c 0c 08 t=31625 But it´s a temperature, and i need the value with a / 1000 division. 31625 realy are 31.625 degress.
If i put
#!/bin/bash SLAVE="/sys/devices/w1_bus_master1/28-80000007e290/w1_slave" OUTPUT=$(/bin/cat $SLAVE | /usr/bin/awk -F 't=' ' { printf $2 / 1000 } ') echo $OUTPUT Give me
root@machine:~ $ /opt/scripts/gettemp.sh 031.625 031.625 is the result, but i don´t know why no put only 31.625 and remove the first 0,
Are i doing something wrong? Could anybody Help me?
Thanks Best Regards
/sys/devices/w1_bus_master1/28-80000007e290/w1_slave? Awk doesn't automatically pad 0's.