File: tail-example.php

Recommend this page to a friend!
  Classes of Matt Frederico  >  TailFile  >  tail-example.php  >  Download  
File: tail-example.php
Role: Example script
Content type: text/plain
Description: Example program
Class: TailFile
Emulates UNIX "tail -f" command
Author: By
Last change:
Date: 18 years ago
Size: 1,111 bytes
 

Contents

Class file image Download
#!/usr/bin/php -q
<?
# ----------------------------------------------
# Program : tail-example.php
# Version : 1.0
# Author : Matthew Frederico
# Date : March 21 2002
# ----------------------------------------------

/****************************/
/* Configuration parameters */
/****************************/
# File Locations

$tailfile = "/var/log/maillog";

# How long to delay between checks on the log
# file updates

$check_delay = 5;

/**********************************************/
/* M A I N P R O G R A M */
/**********************************************/
include("tailfile.phpc"); // PHP Tail class.

// This is where we watch our mail log for updates
//---------------------------------------------
$t = new TailFile($tailfile);
print
"Watching mail log... \n";

while (
$t->isOpen())
{
       
$t->checkUpdates();
       
$myres = $t->getResults();

        if (
$myres)
                print
$myres;
       
       
$t->wait($check_delay);
}
//---------------------------------------------


For more information send a message to info at phpclasses dot org.