led_status

From Mammoth Macaw, 6 Years ago, written in Bash, viewed 255 times.
URL https://paste.steamr.com/view/5414f884 Embed
Download Paste or View Raw
  1. #!/bin/sh
  2.  
  3. test -c /dev/ttyS0 || exit
  4.  
  5. stty -F /dev/ttyS0 9600
  6.  
  7. Mac=`ifconfig | grep -Eiwoh '[a-z0-9:]{17}' | tr '\n' ';'`
  8.  
  9. Status=`wget -q -O - http://the.displays.cpsc.ucalgary.ca/presentation/begin/$Mac \
  10.         | grep -Eoh "room_status[^\"]*" \
  11.         | tail -n 1 \
  12.         | awk '{print $2}'`
  13.  
  14. if [[ "$Status" == "available" ]] ; then
  15.         # turn light green
  16.         echo -e "\xFE\x00" > /dev/ttyS0
  17. else
  18.         # turn light red
  19.         echo -e "\xFE\x01" > /dev/ttyS0
  20. fi
  21.  

Reply to "led_status"

Here you can reply to the paste above