Skip to main content
Home
badllama.com
  • Search
  • Log In

Quickly scan a list of IP addresses

cpeters's picture

Tue, 10/15/2013 - 13:17 by cpeters

This bash script makes it easy to quickly ping an existing list of IPs:

#!/bin/bash
set -m 

forkme() {
RECIEVED=`ping -c 1 $1 | grep '1 received' &`
        if [ -z "$RECIEVED" ]
        then
                echo "$1 reports down"
        else
                echo "$1 reports up"
                unset RECIEVED
        fi
}

while read line
do
        forkme $line &
done

while [ 1 ]; do fg 2> /dev/null; [ $? == 1 ] && break; done

To run it, use the following command:

./scanip.sh < IP.List.txt | grep -v forkme > Results.txt
Powered by Backdrop CMS