Solved

Stream content of a file to php website

Posted on 2008-06-11
2
190 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

810 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