MalibuNL
June 22nd, 2010, 07:55 AM
Hi all,
I was using OpenSuse before, and due a crash - decided to go back to ubuntu.
I wrote a script in OpenSuse to measure temperatures from one of my snmp-enabled devices.
The script was running great and smoothless on OpenSuse, but when i transfer it to Ubuntu, it runs with errors, and some of the output is incorrect.
I've spent 1,5 day now finding why, but i cant find it - hope someone might be able to help me further.
The script as im running is this one:
#!/bin/bash
temp1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.1.1.7.2716713264`
humi1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.2.1.7.976244450`
dew1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.3.1.7.2634873273`
temp2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.1.1.7.2628357572`
humi2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.2.1.7.2804425567`
dew2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.3.1.7.1807639405`
leak=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.2.10.1.7.399845582`
t1=${temp1##S* }
t1p=${#t1}-2
t1=${t1:0:$t1p}.${t1:$t1p:2}
h1=${humi1##S* }
d1=${dew1##S* }
t2=${temp2##S* }
t2p=${#t2}-2
t2=${t2:0:$t2p}.${t2:$t2p:2}
h2=${humi2##S* }
d2=${dew2##S* }
l1=${leak#S* }
l1p=${#l1}
l1=${l1:11:$l1p }
dd=`date +%Y-%m-%d\ %T`
mysql -u Temp_Check -ppassword -h localhost -D Temp_srvroom -e "insert temperature values('${dd}',${t1},${h1},${d1},${t2},${h2},${d2} ,'${l1}')"
exit 0
Errors i receive are:
")syntax error: invalid arithmetic operator (error token is "
")syntax error: invalid arithmetic operator (error token is "
")syntax error: invalid arithmetic operator (error token is "
: numeric argument requirede 24: exit: 0
Thanks in advance. Hope to learn alot about ubuntu in the future - as im an old Suse user :lolflag:
I was using OpenSuse before, and due a crash - decided to go back to ubuntu.
I wrote a script in OpenSuse to measure temperatures from one of my snmp-enabled devices.
The script was running great and smoothless on OpenSuse, but when i transfer it to Ubuntu, it runs with errors, and some of the output is incorrect.
I've spent 1,5 day now finding why, but i cant find it - hope someone might be able to help me further.
The script as im running is this one:
#!/bin/bash
temp1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.1.1.7.2716713264`
humi1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.2.1.7.976244450`
dew1=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.3.1.7.2634873273`
temp2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.1.1.7.2628357572`
humi2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.2.1.7.2804425567`
dew2=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.1.3.1.7.1807639405`
leak=`/usr/bin/snmpget -v 1 -c Bla 172.19.37.253 .1.3.6.1.4.1.5528.100.4.2.10.1.7.399845582`
t1=${temp1##S* }
t1p=${#t1}-2
t1=${t1:0:$t1p}.${t1:$t1p:2}
h1=${humi1##S* }
d1=${dew1##S* }
t2=${temp2##S* }
t2p=${#t2}-2
t2=${t2:0:$t2p}.${t2:$t2p:2}
h2=${humi2##S* }
d2=${dew2##S* }
l1=${leak#S* }
l1p=${#l1}
l1=${l1:11:$l1p }
dd=`date +%Y-%m-%d\ %T`
mysql -u Temp_Check -ppassword -h localhost -D Temp_srvroom -e "insert temperature values('${dd}',${t1},${h1},${d1},${t2},${h2},${d2} ,'${l1}')"
exit 0
Errors i receive are:
")syntax error: invalid arithmetic operator (error token is "
")syntax error: invalid arithmetic operator (error token is "
")syntax error: invalid arithmetic operator (error token is "
: numeric argument requirede 24: exit: 0
Thanks in advance. Hope to learn alot about ubuntu in the future - as im an old Suse user :lolflag: