Sensor readings script

Sensor values download script for Linux bash.

Edit correct HOSTIP, and PARAM (if needed) and save the file (“sensors.sh” for example). Execute it from the Linux console. Sensors values are saved in a “dump.xml” file.

Parameters:

  • id - Dump for sensor with the specified ID;

  • txt=true - CSV dump;

#!/bin/sh # measurements result script # host address HOSTIP="192.168.1.190" # user name USERNAME="guest" # user password PASSWORD="guest" # dumplog file DUMPFILE="dump.xml" # parametrs PARAM="" #here: dump - in text form, only for sensor with id=1001 # PARAM="&txt=true&id=1001" # 1) hash HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'` # 2) authorization RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" "${HOSTIP}/engine.htm"` # 3) session key KEY=`echo -n ${RESPONSE} | awk -F"\"" '{print $4}'` # 4) unloading dump curl -s "${HOSTIP}/dump.htm?k=${KEY}${PARAM}" -o ${DUMPFILE}