note 24753 added to function.popen
| From: | Joelle dot Stringer at sun dot com | Date: | Tue, 27 Aug 2002 19:18:51 +0000 |
| Subject: | note 24753 added to function.popen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35752@lists.php.net to get a copy of this message | ||
Can someone please HELP me out?
I am trying to figure out a way to pipe in a file, in real-time, as it is being created by a
background process.
Currently it is waiting to read until my while is done before it even loads the page. I want to
watch the file as it is being appended too.
Any ideas?
Current Code:
shell_exec("nohup $cmdL >/dev/null 2>&1 &");
if (!file_exists($filename)) {
touch($filename); // Create blank file
chmod($filename,0666);
}
$fd = fopen($filename, "r");
while ($flag) {
if( !feof ($fd) ) {
$buffer = fgets($fd, 4096);
echo(nl2br($buffer));
if( strstr($buffer, $str_error) || strstr($buffer, $str_done ) ) {
$flag = 0; // Stop reading the file.
}
}
}
fclose($fd);
Thanks,
Joelle
--
http://www.php.net/manual/en/function.popen.php
http://master.php.net/manage/user-notes.php?action=edit+24753
http://master.php.net/manage/user-notes.php?action=delete+24753
http://master.php.net/manage/user-notes.php?action=reject+24753