Created
December 21, 2016 12:26
-
-
Save danitool/2f9de48550a85450304f1fd2d281d155 to your computer and use it in GitHub Desktop.
check if a MAC device exists on the local network and alerts by sending an email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# MAC watchdog, checks if a MAC device exists on the local network and alerts by sending an email | |
# 2016 by danitool, Tki2000, txutxy | |
CORREO="mi [email protected]" | |
MAC="00:11:22:33:44:55" | |
RANGO_IP=192.168.3.1-254 | |
FLAG=0 | |
while : | |
do | |
MACSTATE=`nmap -v -sP $RANGO_IP|grep $MAC` | |
if [ "$MACSTATE" ] && [ $FLAG -eq 0 ]; then | |
echo -e "Subject:María está en casa." | sendmail $CORREO | |
FLAG=1 | |
elif [ -z "$MACSTATE" ] && [ $FLAG -eq 1 ]; then | |
echo -e "Subject:María se ha ido." | sendmail $CORREO | |
FLAG=0 | |
fi | |
sleep 5m | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment