Skip to content

Instantly share code, notes, and snippets.

@Sitebase
Created April 28, 2016 06:25
Show Gist options
  • Save Sitebase/d95e44549669cb7bb40cf377a9f61469 to your computer and use it in GitHub Desktop.
Save Sitebase/d95e44549669cb7bb40cf377a9f61469 to your computer and use it in GitHub Desktop.
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