Advertisement
Guest User

recibe_rf.sh

a guest
Sep 17th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. #!/bin/bash
  2. # progrado por Juanmol para http://rsppi.blogspot.com
  3. host=localhost
  4. user=root
  5. pass=PASSMYSQL
  6. db=rf
  7. tblsen=sensores
  8. tblreg=registros
  9. sql="/usr/bin/mysql -h $host -u $user -p$pass -e "
  10.  
  11. sensor=$(echo $1 | cut -c1,2,3)
  12. evento=$(echo $1 | cut -c4,5,6)
  13. medida=$(echo $1 | cut -c7,8,9,10)
  14.  
  15. ultimoevento=$($sql "SELECT ultimoevento FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
  16. tipo=$($sql "SELECT tipo FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
  17. descripcion=$($sql "SELECT descripcion FROM $db.$tblsen WHERE codigo LIKE $sensor" | tail -1 );
  18.  
  19. if [ "$ultimoevento" != "$evento" ];
  20. then
  21.         fecha=$(date +%F_%T);
  22.         $sql 'update '$db'.'$tblsen' SET ultimoevento="'$evento'" WHERE codigo="'$sensor'";'
  23.  
  24.         case $tipo in
  25.                 palmada)
  26.                         case $sensor in
  27.                         114)
  28.                                 wget http://192.168.1.2:8989/x10/a4/off -O /dev/null 2> /dev/null;
  29.                         ;;
  30.                         esac
  31.                 ;;
  32.         esac
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement