I think this is similar to the approach the programmer is taking now, only he’s not actually running the tail command.
When typed in a shell:
% tail -f logfile
the -f flag means “follow”, and it keeps displaying new additions to the file as they’re added. It’s great for watching the web server log, for example.
It displays data in real-time as the file is updated, assuming the data is simply appended at the end.
It’s much more efficient than continuiously reading the logfile and scanning to the end to see what’s new every second. As the logfile’s size grows, this apprach will slow down steadily and consume increasing memory.
-David
> On Jan 1, 2015, at 2:06 PM, Keith Smith <techlists@phpcoderusa.com> wrote:
>
>
> 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 - PLUG-discuss@lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
> --
> Keith Smith
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss