Since you cannot install Net::Ping, how about:
if (`ping -c 1 my.test.com` =~ /1 recieved/) {
print "Alive!\n";
}
else {
print "Dead\n";
}
--
Joost downtime n. The period during which a system
is error-free and immune from user input.
| [reply] [d/l] [select] |
Hi There
I just tried the code and when i replace my.test.com with localhost and run the script it tells me that the system is dead....
| [reply] |
Sorry, i just realised the 'recieved' typo. Just one more question, is there any way to do a tcp connect rather than a ping?
| [reply] |
Assuming your server is running a web-server:
use IO::Socket::INET;
$sock = IO::Socket::INET->new(
PeerAddr => 'www.mysite.com',
PeerPort => 80,
Proto => 'tcp');
if ($sock) {
print "yep";
}
else {
print "nope";
}
--twerq | [reply] [d/l] |
Nope. Just changed the spelling and it is still reporting that the server is down, even tho when i run the command it comes back with
1 packets received
| [reply] |
Check out Net::Ping. You can use it to do exactly what you need.
-- Mike
--
just,my${.02} | [reply] |
Oops, sorry.
I forgot to meantion that i was informed that i could not add extra modules to perl....at least thats what i think my sysadmin said.
| [reply] |
I must admit that i am no perl programmer, (in fact i havn't got a clue), but i understand from a friend that this should be pretty easy to do.
Take a look at Webmin.
This systems administration interface could be a life saver for you. Check out the "System and Server Status" section, you should be able to set up a server "watch" pretty easily. The only hurdle would be setting this up, but there is a very nice setup script to help you. And, it is written in Perl! :-)
Update: grrr, I just saw your update for no mods. :( Ask your sysadmin to install webmin, and give you access to it so that you can set up a watch. TMTOWTDI.
-- hiseldl "Act better than you feel" --inner prophet
| [reply] |