Solved

Dynamically tail a log an outputing to an updated html page

Posted on 2000-03-15
5
473 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now