<?php
$now = date("m/j/y h:i:s",time());
include "connect.php";
$now = date("j/m/y h:i:s",time());
$stmt = "Select * FROM arp_table where os is null;";
print '<META HTTP-EQUIV="refresh" CONTENT="300">';
print '<body bgcolor="#FFFFCC">';
echo $now . "<BR>";
$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
$execit = "/usr/local/bin/x $row->IP_ADDRESS > data/$row->IP_ADDRESS 2>&1";
exec($execit);
$fname = trim("/usr/local/apache/htdocs/data/$row->IP_ADDRESS");
$fp = fopen($fname,"r");
$os="Not Found";
while (!feof($fp)) {
$buffer = fgets($fp, 4096);
$pos = strpos($buffer, "FINAL");
if (is_integer($pos)) {
list ($junk, $os) = split(':',$buffer);
$os = trim(substr($os, 1, -2));
$os = substr($os, 0, 49);
// echo "<BR>" . $os . "<BR>";
$stmt2 = "update arp_table set OS = '$os' where serial = '$row->SERIAL'; ";
// echo "<BR>" . $stmt2 . "<BR>";
$sth2 = ibase_query ($dbh,$stmt2);
}
}
echo $row->IP_ADDRESS . "-->";
echo $os . "<BR>";
fclose($fp);
}
ibase_free_result($sth);
ibase_close($dbh);
?>