Skip to content

Instantly share code, notes, and snippets.

@vitali2y
Created August 15, 2021 09:49
Show Gist options
  • Save vitali2y/89ed97ee3f5f5fbfb411bb6b6b09bee9 to your computer and use it in GitHub Desktop.
Save vitali2y/89ed97ee3f5f5fbfb411bb6b6b09bee9 to your computer and use it in GitHub Desktop.
To scan IPs in your local network
#!/bin/sh
# set -x # uncomment for debugging
pingone(){
if ping -w 2 -q -c 1 192.168.1."$1" > /dev/null
then
printf "IP %s is up\n" 192.168.1."$1"
fi
}
NUM=1
while [ $NUM -lt 255 ]; do
pingone "$NUM" &
NUM=$(expr "$NUM" + 1)
done
wait
# ✗ ./ping_script.sh
# IP 192.168.1.1 is up
# IP 192.168.1.152 is up
# IP 192.168.1.117 is up
# ✗
@vitali2y
Copy link
Author

vitali2y commented Jan 7, 2025

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