Solved

Stream content of a file to php website

Posted on 2008-06-11
2
199 Views
Last Modified: 2010-04-21
We have a realtime application that writes lines to a text file (or to a fifo file, depending on how the file is created). Is it possible to display in realtime the content of this file with php or something else in a website? We don't want the user to have to press F5 every second to see what has been added to the file, it should be displayed automatically.
0
Comment
Question by:Commsquare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21759783
If you have a pipe you can try this, but only one user will then be able to read the data. For using normal files this will get more complicated you you need to count the lines and then start again reading the file again.
while(1) {
  $text = file_get_contents('/path/to/log/pipe');
  echo $text;
  echo '<script>window.scrollTo(0, 10000000);</script>' ."\n";
  flush();
  sleep(2);
}

Open in new window

0
 

Author Closing Comment

by:Commsquare
ID: 31466114
Didn't work completely like this, but it put us on the correct track. Tx.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question