Mailinglisten-Archive |
Hallo Michael
ich hab hier ein ping-programm mal programmiert.
Vielleicht hilft Dir das. Der Timeout liegt bei 10.
<?
// Windows - Skript
$a[0]='127.0.0.1';
$a[1]='192.168.0.1';
$a[2]='192.168.0.2';
$a[3]='192.168.0.3';
$a[4]='192.168.0.11';
foreach($a as $i) {
$cmd='ping -n 1 -w 10 '.$i;
exec($cmd, $rt);
echo'<html><body>';
if(preg_grep("/100% Verlust/i",$rt) || preg_grep("/Unbekannter
Host/i",$rt) )
{
echo'<img src="off.jpg">'.$i.'<br>';
}
else
{
echo'<img src="on.jpg">'.$i.'<br>';
}
echo'</body></html>';
} //end Windows-Version
// And the Code for the Linux-Skript
//
//
//$a[0]='127.0.0.1';
//$a[1]='192.168.0.1';
//$a[2]='192.168.0.2';
//$a[3]='192.168.0.3';
//$a[4]='192.168.0.11';
//
//foreach($a as $i) {
// $cmd='ping -c 1 -w 10 '.$i;
// exec($cmd, $rt);
// echo'<html><body>';
// if(preg_grep("/Host Unreachable/i",$rt) || preg_grep("/Unknown
Host/i",$rt))
// {
// echo'<img src="off.jpg">'.$i.'<br>';
// }
// else
// {
// echo'<img src="on.jpg">'.$i.'<br>';
// }
// echo'</body></html>';
//}//end Linux-Version
?>
Gruß Michael
--
===============================================
PureMatic, Hochkreuz 11, 53819 Neunkirchen
http://www.purematic.de | Tel: 02247-757901
===============================================
php::bar PHP Wiki - Listenarchive