Well, actually the script I'm working on is a dns system. So naturally I'd use traceroute, but like in ping .... I find it easier for the command to just return 0 or 1(success or fail). Traceroute returns a LOT and I have no idea how to tell the script if the IP is alive or not using those results.
@gaal: Thanks for the link, I'll see if my supervisor will allow me to install it on our testserver, then I'll see if it'll work.
Actually, traceroute doesn't "return a lot", it returns 0 for success, and 1 for failure, like many programs. It does "output a lot", but that's easy to fix. See if this works for you:
#!/usr/bin/perl
use strict;
use warnings;
# IP adress or hostname of the remote machine to test
my $remote = "192.168.0.2";
if(system("traceroute $remote 1> /dev/null 2>&1"))
{
print "$remote is down\n";
}
else
{
print "$remote is up\n";
}
__END__
Does the 0 for success of traceroute means that it successfully executed the command? or does it mean that it found valid IP's? Sorry I'm new to traceroute.
Thanks for fixing up the script, it takes too long to test though.