#!/bin/bash #Enter your ip of your device here DEVICES="192.168.178.100 192.168.178.36" for i in `echo $DEVICES`; do hping3 -2 -c 10 -p 5353 -i u1 $i -q >/dev/null 2>&1 sleep 1 # Only arp specific device, grep for a mac-address status=`arp -an $i | awk '{print $4}' | grep "..:..:..:..:..:.."` #A mac will be 17 characters including the ":" if [ ${#status} -eq 17 ]; then echo "Phone $i is detected!" if [ $i == "192.168.178.100" ]; then curl http://192.168.178.24:8082/set/0_userdata.0.Anwesenheit.Sabrina?value=1 fi if [ $i == "192.168.178.36" ]; then curl http://192.168.178.24:8082/set/0_userdata.0.Anwesenheit.Rene?value=1 fi else echo "Phone $i is not present" if [ $i == "192.168.178.100" ]; then curl http://192.168.178.24:8082/set/0_userdata.0.Anwesenheit.Sabrina?value=0 fi if [ $i == "192.168.178.36" ]; then curl http://192.168.178.24:8082/set/0_userdata.0.Anwesenheit.Rene?value=0 fi fi done