#!/usr/bin/perl -w use strict; use Net::Ping; use Getopt::Std; my $protocal = "icmp"; my $network = "user must enter"; my $start = 0; my $end = 255; my $timeOut = 1; use vars qw/ $opt_p $opt_N $opt_S $opt_E $opt_T $opt_h/; getopt( "p:N:S:E:T:h" ); if( $opt_p ) {$protocal = $opt_p;} if( $opt_N ) {$network = $opt_N} else { &usage(); exit(); } if( $opt_S ) {$start = $opt_S} if( $opt_E ) {$end = $opt_E} if( $opt_T ) {$timeOut = $opt_T} if( $opt_h ) {&useage(); exit();} my $p = Net::Ping->new($protocal,$timeOut); for(my $node=$start; $node<$end; $node++){ my $address = "$network.$node"; print $address,($p->ping($address) ? ' is alive' : ' is not alive'),"\n"; } $p->close(); sub usage { print< [-p][-S][-E][-T][-h] network actually first 3 octects of an IP address protocal can be icmp, tcp or udp default is icmp start default 0 end default 255 timeout default 1 DOIT }