Skip to content

Instantly share code, notes, and snippets.

@geermc4
Last active October 11, 2015 03:38
Show Gist options
  • Save geermc4/3797292 to your computer and use it in GitHub Desktop.
Save geermc4/3797292 to your computer and use it in GitHub Desktop.
runs action on any device that responds to broadcast ping and has specified port open
BROADCAST=255.255.255.255
SUBNET=192.168.1
PORT=80
ACTION=open #opens default browser on a mac
for e in $(
for i in `ping -c2 $BROADCAST | grep $SUBNET | sed -n "s/.*\($SUBNET.[0-9]\{1,\}\).*/\1/p"`
do
nc -z $i $PORT | sed -n "s/.*\($SUBNET.[0-9]\{1,\}\).*/\1/p"
done)
do
$ACTION "http://$e"
done
@geermc4
Copy link
Author

geermc4 commented Sep 28, 2012

Ment to solve my problem not look pretty nor be readable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment