Here is a simple script to check changes etc. to a
file.
<?php
/* opens a connection to the FAM service daemon
*/
$fam_res = fam_open ();
/*
* The second argument is the
full pathname
* of the file to monitor.
* Note that you can't use
relative pathnames.
*/
$nres = fam_monitor_file ( $fam_res,
'/home/sergio/test/fam/file_to_monitor.log');
while(1){
if(
fam_pending ( $fam_res ) ) $arr = (fam_next_event($fam_res)) ;
switch
($arr['code']){
case 1:
echo
"FAMChanged\n";
break;
case 2:
echo
"FAMDeleted\n";
break;
case 3:
echo
"FAMStartExecuting\n";
break;
case 4:
echo
"FAMStopExecuting\n";
break;
case 5:
echo
"FAMCreated\n";
break;
case 6:
echo
"FAMMoved\n";
break;
case 7:
echo
"FAMAcknowledge\n";
break;
case 8:
echo
"FAMExists\n";
break;
case 9:
echo
"FAMEndExist\n";
break;
default:
break;
}
if(isset($arr)) unset($arr);
/* In order to avoid too much
CPU load */
usleep(5000);
}
/* Close FAM connection
*/
fam_close($fam_res);
?>
Hope this could help.
God
Belss PHP!
regards
Sergio Paternoster