Solved

Stream content of a file to php website

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

763 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