diff --git a/sbin/pinger b/sbin/pinger index 32a1aaa..b33d52f 100755 --- a/sbin/pinger +++ b/sbin/pinger @@ -15,10 +15,10 @@ $| = 1; die("pinger must be run as root\n") if($> != 0); my $alive = 1; -my(%switches, $all, $both, $time, $name, $force, $startTime, $finishTime); +my(%switches, $all, $print, $both, $time, $name, $force, $startTime, $finishTime); # handle command line options -my $status = getopts('abdfrnth', \%switches); +my $status = getopts('abdfrnpth', \%switches); help() if(!$status || $switches{'h'}); for (keys %switches) { switch($_) { @@ -26,6 +26,7 @@ for (keys %switches) { case 'b' { $both = 1; $name = 1; } case 'd' { $alive = 0; } case 'f' { $force = 1; } + case 'p' { $print = 1; } case 'r' { $alive = 1; } case 'n' { $name = 1; } case 't' { $time = 1; } @@ -79,6 +80,10 @@ for(my $i = $start, my $k = 1; $i <= $end; $i++, $k++) { } } + if($print) { + $ip = ($reachable) ? "o $ip" : "x $ip"; + } + if($reachable) { push(@reachable_ips, colored($ip, 'green')); } else { @@ -155,6 +160,7 @@ sub help { print "\t-d\t\tList dead addresses\n"; print "\t-f\t\tForce hostname lookup even if unreachable\n"; print "\t-n\t\tReturn list as hostnames when possible\n"; + print "\t-p\t\tEnable print mode; only noticeable with -a enabled\n"; print "\t-r\t\tList reachable addresses (default)\n"; print "\t-t\t\tTime ping execution\n"; exit(1);