|
List Info
Thread: Use File::Tail on two (2) files at the same time
|
|
| Use File::Tail on two (2) files at the
same time |

|
2007-01-24 06:55:45 |
|
Hi,
I have grabbed and modify a Perl script that opens a log file and use
File::Tail and regexp to fill a DB according to matching wildcards
that appear in that logfile. I would like to modify this script so
that it checks two log files at the same time.
Here's my current script:
$log_file = "/var/log/mail.log"
my $logref=tie(*LOG,"File::Tail",(name=>$log_file,debug=>$debug));
while () {
if (/postfix/(smtp|virtual)[.*status=sent/) {
// do things
} elsif (/postfix/smtp[.*status=deferred/) {
// do other things
};
};
What I would like is the script to look at /var/log/mail.log
and /var/log/messages.log (for example) at the same time.
I can't find how to code this.
Do I need two $logref, can I use things like "while ( and
) {" things, ...
Thanks in advance.
Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|
| Re: Use File::Tail on two (2) files at
the same time |

|
2007-01-24 07:05:40 |
|
12:55pm, joel_carnat wrote:
> Hi,
>
> I have grabbed and modify a Perl script that opens a log file and use
> File::Tail and regexp to fill a DB according to matching wildcards
> that appear in that logfile. I would like to modify this script so
> that it checks two log files at the same time.
>
> Here's my current script:
> $log_file = "/var/log/mail.log"
> my $logref=tie(*LOG,"File::Tail",(name=>$log_file,debug=>$debug));
> while () {
> if (/postfix/(smtp|virtual)[.*status=sent/) {
> // do things
> } elsif (/postfix/smtp[.*status=deferred/) {
> // do other things
> };
> };
>
> What I would like is the script to look at /var/log/mail.log
> and /var/log/messages.log (for example) at the same time.
>
> I can't find how to code this.
> Do I need two $logref, can I use things like "while ( and
> ) {" things, ...
>
I believe the two main approaches here would be to use forks or threads to
split the tasks out (ie each forked copy or each thread handles a different
file), or to use the four-arg version of select with a short timeout value
to poll each file in turn.
Paul
Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|
| Re: Use File::Tail on two (2) files at
the same time |

|
2007-01-24 11:34:59 |
|
| >>>>> "joel" == joel carnat altran.com> writes:
joel> I have grabbed and modify a Perl script that opens a log file and use
joel> File::Tail and regexp to fill a DB according to matching wildcards
joel> that appear in that logfile. I would like to modify this script so
joel> that it checks two log files at the same time.
POE should be able to do this rather trivially, with POE::Wheel::FollowTail.
See poe.perl.org for an overview.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
stonehenge.com>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|
[1-3]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|