I would start with jQuery Ajax. Sounds like you need jQuery to query a PHP script that executes tail and returns the results back to your jQuery code where it assembles the log text in a way that can then be sent to the DOM element or a text box. All you need is a trigger to keep it refreshing - a button or maybe there is a timer in jQuery that will trigger your Ajax script.

On 2015-01-01 13:26, David Schwartz wrote:
Happy New Year, all!

I have a general php/scripting question.

I’ve got a guy working on a php script for me and I want it to create
a logfile. Piece of cake. The logfile is being created.

I also want to be able to view the logfile inside of an HTML TEXTBOX
in a Wordpress admin page. (That’s just context; the question has
nothing to do with WP at all.)

In my mind, it’s essentially what you’d get if you did ‘tail -f
logfilename’ and piped it into a circular buffer that’s displayed in
an HTML TEXTBOX, using a little javascript to update the contents of
the TEXTBOX periodically.

As if the TEXTBOX is just a command shell window that shows the
results of the ‘tail -f’ command, but you can’t type into it.

Here’s my question: is it possible to spawn a thread running something
like rsh to process a ‘tail -f <fname>’ command and take the output
from that and display it in an HTML TEXTBOX as if it were just typed
at the command line?

Note that I don’t need an infinite history, just 100 lines or so.

Later on I want to add something like a grep filter so it only
displays lines that match a specific ID, but for now we just need to
get the log file to show up “live” without causing problems.

The programmer is having coniption fits trying to write some rather
complicated php+js code to get this to work, and it’s causing buffer
overflows with the code managing the TEXTBOX that’s impacting other
stuff.

I’m thinking … what’s wrong with just running a ‘tail -f’ command
through a shell and displaying the results in a web page?

That’s the beauty of Linux, right?

Any thoughts?

-David



---------------------------------------------------
PLUG-discuss mailing list - [email protected]
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss

--
Keith Smith
---------------------------------------------------
PLUG-discuss mailing list - [email protected]
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss

Reply via email to