Hi all, Here my two CGI scripts to return an XML file from data read from owfs, the 1wire filesystem.
These scripts could be useful to get data from 1wire devices and integrate them into web apps, like AJAX or else. Before execute these script, you have to read 1/ Dallas 1 wire device interfacing with owfs http://www.acmesystems.it/?id=29 2/ Setting up BOA to accept CGI http://www.acmesystems.it/?id=209 The scripts... - first script get all data from owfs. Could be long !. - second script get only 'type' and 'temperature' data from owfs <----- start -----> #!/bin/sh path_1wire=/tmp/1wire getcontent() { cat $1/$2 | tr -d ' \n\r' } echo "Content-Type:text/xml; charset=ISO-8859-1\n" echo "<ow>" for device in $(ls $path_1wire | grep -i '[0-9a-z\.]\{14\}') do echo "<device id=\"$device\">" for param in $(ls $path_1wire/$device) do printf "<%s value=\"%s\" />" $param $(getcontent $path_1wire/$device $param) done echo "</device>" done echo "</ow>" <----- end -----> <----- start -----> #!/bin/sh path_1wire=/tmp/1wire getcontent() { cat $1/$2 | tr -d ' \n\r' } echo "Content-Type:text/xml; charset=ISO-8859-1\n" echo "<ow>" for device in $(ls $path_1wire | grep -i '[0-9a-z\.]\{14\}') do echo "<device id=\"$device\">" for param in $(ls $path_1wire/$device) do case $param in 'temperature' | 'type' ) printf "<%s value=\"%s\" />" $param $(getcontent $path_1wire/$device $param) ;; esac done echo "</device>" done echo "</ow>" <----- end -----> Just my first unix shell on the FOX. http://www.shellunix.com/sh.html (to know more about shell in french) Olivier
