Login   Register  
PHP Classes
elePHPant
Icontem

File: tail-example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Matt Frederico  >  TailFile  >  tail-example.php  >  Download  
File: tail-example.php
Role: ???
Content type: text/plain
Description: Example program
Class: TailFile
Emulates UNIX "tail -f" command
Author: By
Last change:
Date: 2002-03-22 01:08
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);
}
//---------------------------------------------