Skip to content

Instantly share code, notes, and snippets.

@prameshbajra
Created January 7, 2020 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prameshbajra/1a27a945c283bf54b56e5998a8e195bd to your computer and use it in GitHub Desktop.
Save prameshbajra/1a27a945c283bf54b56e5998a8e195bd to your computer and use it in GitHub Desktop.
Gives the list of IPs that are Busy or Open.

Execute this by:

(777 might be an over kill for this one) sudo chmod 777 available_ip.sh

./available_ip.sh

#!/bin/sh
# Uncomment for debugging
#set -x
pingf(){
if ping -w 2 -q -c 1 192.168.1."$1" > /dev/null ;
then
printf "IP %s is up\n" 192.168.1."$1"
else
printf "IP %s is open\n" 192.168.1."$1"
fi
}
main(){
NUM=1
while [ $NUM -lt 255 ];do
pingf "$NUM" &
NUM=$(expr "$NUM" + 1)
done
wait
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment