Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stream content of a file to php website

Posted on 2008-06-11
2
Medium Priority
?
208 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 1500 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

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.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

715 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