Re: file like, regular expression driven, content splitter
- From: Eli the Bearded <*@eli.users.panix.com>
- Date: Mon, 5 Dec 2011 06:56:30 +0000 (UTC)
In comp.os.linux.misc, Markus <markus.mj@xxxxxxxxx> wrote:
My idea is something like virtual device instead of the applog.log
file which would be configured with regular expression rerouting every
incoming line into separate log file. Filter is driven by the regex in
configuration.
Named pipes. One side writes to a file name, one side reads from it,
it works just like a | on the command line. Creation is simple:
mknod applog.log p
Both sides open it like a regular file, one to write and read. The
writer will block if the pipe fills up, so the reader client should
start first. Example reader:
#!/usr/bin/perl -w
open(INPUT, '<', 'applog.log') || die "$0: can't read log!";
open(OUT1, '>', ...
open(OUT2, '>', ...
...
open(OUTN, '>', ...
while(<INPUT>) {
if(/pattern1/) { print OUT1; next; }
if(/pattern2/) { print OUT2; next; }
...
# default fallback
print OUTN;
}
__END__
Elijah
------
test carefully, the writer will block if the reader dies
.
- Follow-Ups:
- References:
- Prev by Date: Re: You are being tracked
- Next by Date: Re: DVD-bak get2 DOS:8.3 FileNames?
- Previous by thread: Re: file like, regular expression driven, content splitter
- Next by thread: Re: file like, regular expression driven, content splitter
- Index(es):
Relevant Pages
|