Link to home
Start Free TrialLog in
Avatar of nathanmx
nathanmxFlag for United States of America

asked on

Creating a simple Ping Script - need help

I am looking to find/learn to create a simple script that can ping servers to see if they are down or not. I have searched online in tons of places and come up with a php script, but I don't have enough permissions to use the exec() commands. Could anyone help me create / point me in the direct of a script in any language that would enable to me ping specific servers that does not require administrative permission? Thanks.

Below is what I have thus far:

<?php
echo "Server Status by IP:<br>";

$sites = array();
$sites[] = '';  
$sites[] = '127.0.0.1';

foreach($sites as $ip) {
// system() / shell_exec() / exec() - none work
$cmd = shell_exec("ping -c 1 -w 1 $ip");
$ping_results = explode(",",$cmd);
if (eregi ("0 received", $ping_results[1], $out)) { echo "Server is down"; }
if (eregi ("1 received", $ping_results[1], $out)) { echo "Server is up"; }
}
?>


Thanks,
Nathan
ASKER CERTIFIED SOLUTION
Avatar of georgecooldude
georgecooldude

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmelika
jmelika

This ASP script requires installing a component on the server.  Not sure if that's possible for you since you asked for a non-administrative permission script, but here it is anyway:
http://www.serverobjects.com/products.htm (scroll all the way to the bottom for ASPPing)

What is the web server that you are using?  That'll help us give you a more appropriate scripting language.

JM
Avatar of nathanmx

ASKER

I looked at that one previously and dismissed it, but since no other one worked, I had to try it. I ended up using only about 10% and doing 90% of my own coding, but the result worked. So I believe thanks is in order. ;)