Solved

Dynamically tail a log an outputing to an updated html page

Posted on 2000-03-15
5
500 Views
Last Modified: 2012-06-27
Can anyone tell me how to dynamically "tail" a file an output it an updating html page in unix.  I was thinking of using a meta refresh or maybe some javascript but can remember how to do it.
Thanks
0
Comment
Question by:mragg
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 2622879
You can make the html page refresh every minute easily by using meta tags or just plain javascript, fi:

<body onload=setrefresh();>

<script language=javascript>
  function setrefresh()
  {
    setTimeout ('document.history.go(0)', 60000);
  }
</script>

That will force it to refresh every minute.

I'm not sure what you want to update the html page with, but say you have a script that allows single log entries into STDIN and uses them to update the html page. You can then easily use a command like:

tail -f /usr/local/apache/logs/error_log > myscript

Which should accomplish what you want it to.

Tom.
0
 
LVL 1

Expert Comment

by:greebo
ID: 2622889
To refresh an HTML page it's easier to use a meta-tag like this :
<Meta Http-equiv="Refresh" Content="30">
This will refresh every 30 seconds.
0
 

Author Comment

by:mragg
ID: 2625118
The part that I really needed to know was if the web page could do the tail - like if there was a java script that could tail the file.  I dont want to have a script that is constantly running. It is for a logfile.

The javascript portion was also what I wanted to know so I will award binkzz if no one else answer soon
0
 
LVL 4

Accepted Solution

by:
binkzz earned 100 total points
ID: 2627131
You can't have javascript tail log files because for security reasons javascript can access neither serverside or clientside filesystems. The best you can really do is to tail straight into an html file that starts with:

<html>
<body>
<pre>

And after that you do the `tail -f logfile >> htmlfile`.

I think that's the closest you can get to your solution without resulting to java applett solutions.

Tom
0
 

Author Comment

by:mragg
ID: 2629448
I thought so, but just checking.

Thanks
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

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

803 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