Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # progrado por Juanmol para http://rsppi.blogspot.com
- host=localhost
- user=root
- pass=PASSMYSQL
- db=rf
- tblsen=sensores
- tblreg=registros
- sql="/usr/bin/mysql -h $host -u $user -p$pass -e "
- sensor=$(echo $1 | cut -c1,2,3)
- evento=$(echo $1 | cut -c4,5,6)
- medida=$(echo $1 | cut -c7,8,9,10)
- ultimoevento=$($sql "SELECT ultimoevento FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
- tipo=$($sql "SELECT tipo FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
- descripcion=$($sql "SELECT descripcion FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
- if [ "$ultimoevento" != "$evento" ];
- then
- fecha=$(date +%F_%T);
- $sql 'update '$db'.'$tblsen' SET ultimoevento="'$evento'" WHERE codigo="'$sensor'";'
- case $tipo in
- palmada)
- case $sensor in
- 114)
- wget http://192.168.1.2:8989/x10/a4/off -O /dev/null 2> /dev/null;
- ;;
- esac
- ;;
- esac
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement