For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2004 > reading log files in real time









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author reading log files in real time
Adrian Farrell

2004-07-28, 8:56 pm

Hi,

I'm looking for a way to read log files in real time, so that each time a
new entry appears in the file I can perform a search/query (whatever
really!) on it.

it's odd really, as I expected this to be a very common scenario and yet I
can find nothing on it!

I think there maybe some way to achieve this using the s and tell
commands but I can't quite fathom it out.

any suggestions?

thanks,
Ad
----------------------------------------------------------------------------------------------------------------------------------------------------------------

<<Disclaimer>>
This message contains confidential information and is intended only for the
named individual. If you are not the named addressee, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this message in error and delete
this e-message from your system.

E-mail transmission cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, delayed in
transmission, incomplete, or may contain viruses. The sender therefore does
not accept liability for any errors or omissions in the contents of
this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This message
is provided for informational purposes and should not be construed as a
solicitation or offer to buy or sell any securities or related financial
instruments.


Ramprasad A Padmanabhan

2004-07-28, 8:56 pm

use File::Tail;

Ram

On Mon, 2004-07-26 at 18:19, Adrian Farrell wrote:
> Hi,
>
> I'm looking for a way to read log files in real time, so that each time a
> new entry appears in the file I can perform a search/query (whatever
> really!) on it.
>
> it's odd really, as I expected this to be a very common scenario and yet I
> can find nothing on it!
>
> I think there maybe some way to achieve this using the s and tell
> commands but I can't quite fathom it out.
>
> any suggestions?
>
> thanks,
> Ad
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> <<Disclaimer>>
> This message contains confidential information and is intended only for the
> named individual. If you are not the named addressee, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately by e-mail if you have received this message in error and delete
> this e-message from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free as
> information could be intercepted, corrupted, lost, destroyed, delayed in
> transmission, incomplete, or may contain viruses. The sender therefore does
> not accept liability for any errors or omissions in the contents of
> this message which arise as a result of e-mail transmission. If
> verification is required please request a hard-copy version. This message
> is provided for informational purposes and should not be construed as a
> solicitation or offer to buy or sell any securities or related financial
> instruments.
>
>


Adrian Farrell

2004-07-28, 8:56 pm


Rampra,

thanks for the heads up on File::Tail;

unfortunatley the module isn't installed and we have a very tight
restricttions on what we can install on production servers (banks are like
that!!!).

so I'm back needing to find a way to do it with the tell and s commands,

thanks,
Ad




Rampra A
Padmanabhan
To
26/07/2004 14:08 Adrian Farrell/UK/INSTINET@Instinet
cc
perl beginners <beginners@perl.org>
Subject
Re: reading log files in real time










use File::Tail;

Ram

On Mon, 2004-07-26 at 18:19, Adrian Farrell wrote:
> Hi,
>
> I'm looking for a way to read log files in real time, so that each time a
> new entry appears in the file I can perform a search/query (whatever
> really!) on it.
>
> it's odd really, as I expected this to be a very common scenario and yet

I
> can find nothing on it!
>
> I think there maybe some way to achieve this using the s and tell
> commands but I can't quite fathom it out.
>
> any suggestions?
>
> thanks,
> Ad
>

----------------------------------------------------------------------------------------------------------------------------------------------------------------

>
> <<Disclaimer>>
> This message contains confidential information and is intended only for

the
> named individual. If you are not the named addressee, you should not
> disseminate, distribute or copy this e-mail. Please notify the sender
> immediately by e-mail if you have received this message in error and

delete
> this e-message from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free as
> information could be intercepted, corrupted, lost, destroyed, delayed in
> transmission, incomplete, or may contain viruses. The sender therefore

does
> not accept liability for any errors or omissions in the contents of
> this message which arise as a result of e-mail transmission. If
> verification is required please request a hard-copy version. This message
> is provided for informational purposes and should not be construed as a
> solicitation or offer to buy or sell any securities or related financial
> instruments.
>
>



--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>





Wiggins D Anconia

2004-07-28, 8:56 pm

Please bottom post, this thread is unreadable.

>
> Rampra,
>
> thanks for the heads up on File::Tail;
>
> unfortunatley the module isn't installed and we have a very tight
> restricttions on what we can install on production servers (banks are like
> that!!!).
>


Sillieness (I know), but still silly.

> so I'm back needing to find a way to do it with the tell and s

commands,
>


perldoc -q tail
perldoc -f select

There are also several modules in IO:: on CPAN or part of core that can
help with this, particularly IO::Select. Generally the 4 argument form
of 'select' will get you where you are going

Network Programming with Perl has excellent examples related to reading
from sockets (though any filehandle works the same) on how to use select
effectively.

Give it a shot and post more questions if you get stuck,

http://danconia.org

<snip>
[color=darkred]
>
> On Mon, 2004-07-26 at 18:19, Adrian Farrell wrote:
time a[color=darkred]
> I

<snip>

Ramprasad A Padmanabhan

2004-07-28, 8:56 pm

On Tue, 2004-07-27 at 19:50, Wiggins d Anconia wrote:
> Please bottom post, this thread is unreadable.
>
>
> Sillieness (I know), but still silly.
>
> commands,
>
> perldoc -q tail
> perldoc -f select
>
> There are also several modules in IO:: on CPAN or part of core that can
> help with this, particularly IO::Select. Generally the 4 argument form
> of 'select' will get you where you are going
>
> Network Programming with Perl has excellent examples related to reading
> from sockets (though any filehandle works the same) on how to use select
> effectively.
>
> Give it a shot and post more questions if you get stuck,
>
> http://danconia.org
>
> <snip>
>
> time a
>
> <snip>



I think you should use CPAN modules instead of reinventing the wheel.
You can either convince the admin to install the modules for you ( After
all there are no security issues with File::Tail ) , or you can do a
special install as a non-root user.

Thanks
Ram




>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com