Blog ≫ 2016 ≫ Test - who's in the house?

This is working quite nicely, here's a sample:

  Back door
      Drive
      HUMAX
      Kitchen away since 08:45
      Macbook
      NAS drive
      Nest Labs Inc.
      Clare away since 08:34
      Paul
      pi 2 (study)
      pi 3 (sense)
      Raspbrewery
      router
      wifi link

Just a sample of course I'm not publishing info on when we go in and out up here... code is something like this:

#!/bin/bash
    DOCROOT=/var/www
    FOLDER=${DOCROOT}/devices
    arp-scan -l --interface=wlan0 --retry=3 | grep 192.168 > /tmp/arp-scan.txt
    while read LINE; do
      FILE=$(echo "${LINE}" | cut -f2).txt
      NAME=$(echo "${LINE}" | cut -f3)
      echo ${NAME} > ${FOLDER}/${FILE}
      if [ -f ${FOLDER}/.alias.${FILE} ]; then
        cp ${FOLDER}/.alias.${FILE} ${FOLDER}/${FILE}
      fi
    done < /tmp/arp-scan.txt
    DATE=$(date +%s)
    for FILE in $(ls -1tr ${FOLDER}); do
      MTIME=$(stat -c %Y ${FOLDER}/${FILE})
      DIFF=$(expr ${DATE} - ${MTIME})
      STATUS=
      EXPLANATION=''
      if [ ${DIFF} -gt 60 ]; then
        if [ ${DIFF} -gt 300 ]; then
          EXPLANATION="away since $(ls -l ${FOLDER}/${FILE} | cut -c27-38)"
          STATUS=
        else
          STATUS=
        fi
      fi
      echo ${STATUS} $(cat ${FOLDER}/${FILE}) ${EXPLANATION}
    done

I really like unicode in bash scripts, it just looks so wrong 1.

  1. Hmm at some point the unicode characters like 🖥 and 🎮 all disappeared again...

🕵️

⬅️ :: ➡️

Paulʼs blog - I live in A sleepy town in the deep South. Wednesday + dad to 2, I am a full-stack web engineer, and I do js / node, some ruby, python, php ect ect. I like pubs, parkrun, eating, home automation 🤖 and other diy jiggery-pokery, history, family tree stuff, television, squirrels, pirates ☠️, lego, + TIME TRAVEL.