#!/usr/bin/perl
#
# Author: Peter Keel <killer@discordia.ch>
# 
# Iterates through a subnet. 
#

die "Usage: $0 [aaa.bbb.ccc]\n" unless ($ARGV[0]);

$net = $ARGV[0];
$start=1;
$end=254;

while ($start < $end) { 
    $server="$net.$start";
    chomp(@ping = qx!/bin/ping -c 1 $server!);
	foreach $_ (@ping) {
    	    if (/0\% packet loss/) { 
		print STDOUT "$server\n";
	    }
	}
    $start++;
}
