Last active
October 11, 2015 03:38
-
-
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
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ment to solve my problem not look pretty nor be readable :)