How can I make a script to see if a computer is online, I was thinking of pinging the computer but I cant figure out how. I tried this but it just gave me aborted.
<?php
$myShellString = "netstat -n -a | grep 24.67.64.93:1139 |
wc -l";
$myStatus = shell_exec($myShellString);
echo " $myStatus ";
if ($myStatus = 0) {
echo "Server is Online";
} elseif ($myStatus = 1) {
echo "Server Offline 1";
} elseif ($myStatus = 2) {
echo "Server Offline 2";
} else {
echo "Server Detect Error";
};
?>
Checking to see if a computer is online?
Moderator: General Moderators
how about a simple?
Code: Select all
exec ("ping $host",$notWanted,$retval);
if($retval==0)
// host on
else
// host offWill your host not let you ping at all (have you tried pinging the bbc for example)? If it is you can always ask your host to turn it back on, stranger things have happened.
Is the windows xp machine set up to serve pages? If it is you could always go about it back to front and have the site try to collect a file or image etc from the windows xp box. If it can't get the file the box is not online. Bit of a clunky solution though
.
Is the windows xp machine set up to serve pages? If it is you could always go about it back to front and have the site try to collect a file or image etc from the windows xp box. If it can't get the file the box is not online. Bit of a clunky solution though
any open socket you may misuse? i.e.
(DAMIT, it's open on my box, too
)
Code: Select all
$sd = fsockopen ( $host, 445, $errNo, $errStr, 4);
if ($errNo != 0)
print('offline '.$errNo);
else
fclose($sd);