Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Detect if a certain device is on the network or not. This should work better then a regular ping when you want to check for example phones that go into deep sleep mode.
# usage ./device-detect.sh 192.168.1.5
nmap -sn $1 | grep -q latency
result=$?
if [ "$result" -eq "1" ];
then
echo "Device is offline"
else
echo "Device is online"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment