Click to See Complete Forum and Search --> : Testing for live IP's in perl/php?
Elijah
07-29-2004, 11:52 PM
I've tried ping but it's not very reliable for IP's having firewalls, the ping will never come back and the script will erroneously report that the IP is down but is actually a 'live' one. It's the simplest to make though:
#!/usr/bin/perl
# IP adress or hostname of the remote machine to test
$remote = "192.168.0.2";
if(system("ping -c 1 $remote 1> /dev/null"))
{
print "$remote is down\n";
}
else
{
print "$remote is up\n";
}
how to do this in traceroute? I have no clue ... anyone got any ideas?? :confused:
chrism01
08-02-2004, 04:10 AM
If you just want the results, without having to write all the code, try this module:
http://search.cpan.org/~hag/Net-Traceroute-1.08/Traceroute.pm
Elijah
08-02-2004, 04:53 AM
Thanks, I wish I could use that right away as I don't have root access to install those modules... so I'm struggling reinventing the traceroute wheel :o
Suramya
08-02-2004, 11:14 AM
You should be able to copy the module to the same directory as your code and include it. Thats what I did when I didn't have root access at work.
One thing you have to remember is that you have to recreate the directory structure. Meaning, if you are including Mail::IMAPClient then you create a directory Mail and put the IMAPClient under it.
Hope this helps.
- Suramya
chrism01
08-03-2004, 03:37 AM
You can do as Suramya said, or try this:
http://search.cpan.org/src/HAG/Net-Traceroute-1.08/Traceroute.pm
which is the src code link off that page. Just obey the legal injunctures if you use it. See top of the page.
Attached is something that I did a long time ago in PHP. I don't know if it works but you can test it and see if it is worth something...