Re: tail -f into web page
| From: | Curt Zirzow | Date: | Fri, 26 Mar 2004 03:34:50 +0000 |
| Subject: | Re: tail -f into web page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181538@lists.php.net to get a copy of this message | ||
* Thus wrote CurlyBraces Technologies ( Pvt ) Ltd (curlybraces@dialogsl.net):
> hi friends ,
>
> I have a log file that is creating while running a perl script.That log can i read ( using,
> tail -f log.file ) in to a web interface from php ?
> Is there any possibility , plz help ..........,
You can possibly do something with using
popen and some connection handling functions.
/* ensure the script wont time out */
set_time_limit(0);
/* send data after each echo */
ini_set('implicit_flush', 1);
/* watch for canceled request */
ignore_user_abort(false);
/* open a process file pointer */
$pfp = popen('tail -f log.file', 'r');
/* make sure it worked */
if (! $pfp ) {
die('Can\'t open file');
}
/* continue while the user hasn't aborted or
we've still have a connection */
while (! connection_aborted() ) {
/* get a line and echo the contents
from the file pointer opened */
echo fgets($pfp);
}
/* close the process file pointer */
fclose($pfp);
See:
http://us2.php.net/manual/en/features.connection-handling.php
http://php.net/popen
http://php.net/ini_set
Curt
--
"I used to think I was indecisive, but now I'm not so sure."