#!/usr/bin/perl

# Replacement for ping supplied with Redhat 6.n
# problem is that it never returns when a host is down

# n.b. this file must be run setuid root - be very careful!
# John Phillips April 2000

use Net::Ping;

$host="xntl-router";

$p=Net::Ping->new(icmp,5,64);

foreach $host (@ARGV) {
	if ($p->ping($host)) {
		print "$host is alive\n";
		$exitcode=0 unless $exitcode==-1;
		}
	else
		{
		print "$host unreachable\n";
		$exitcode=-1;
		}
	}
$p->close();

exit ($exitcode);
