Skip to content

Instantly share code, notes, and snippets.

@jgrevich
Created July 11, 2014 02:08

Revisions

  1. jgrevich created this gist Jul 11, 2014.
    30 changes: 30 additions & 0 deletions door_bell.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/bash

    # setup constants
    CURRENT_LIST_PATH=/tmp/wifi_client_macs_current
    PREVIOUS_LIST_PATH=/tmp/wifi_client_macs_previous

    while [ "true" ]
    do
    # backup old file if it exists
    if [ -f $CURRENT_LIST_PATH ];
    then
    cp $CURRENT_LIST_PATH $PREVIOUS_LIST_PATH
    fi

    # grab MACs from 2.4Ghz radio
    wl -i eth1 assoclist | cut -d" " -f2 > $CURRENT_LIST_PATH

    # grab MACs from 5Ghz radio
    wl -i eth2 assoclist | cut -d" " -f2 >> $CURRENT_LIST_PATH


    # do something if desired mac appears in list
    if grep -Fxq "3C:15:C2:18:F1:8F" $CURRENT_LIST_PATH
    then
    echo "Justin is home"
    else
    printf "."
    fi
    sleep 1
    done