mda2 has asked for the wisdom of the Perl Monks concerning the following question:
Update
IO reduces is a needs for content-filter on smtp servers
Postfix don't use redirection on call after-queue
It's work with redirection, but don't with my needs :(
I'm working on a content filter on Postfix, and need exec antivirus, anti spam and usualy write content to debug, but it's a heavy host and need to reduce disk io.
I'm working on a content filter on Postfix, and need exec antivirus, anti spam and usualy write content to debug, but it's a heavy host and need to reduce disk io.
On my tests seek and tell functions working on STDIN, when exec with redirect, but a question "is it correct or can fail on future" ?
My relevant code:
filter.pl < filter.pl
Code more complex:print "." while ( <STDIN> ); print "\n"; seek(STDIN,0,0); print "," while ( <STDIN> ); print "\n";
My code need this reduce io...
use strict; my ( $dfrom, $dsubj ); my $from = shift; while ( defined( $_ = <STDIN> ) ) { if ( substr($_,0,5) eq 'From:' ) { chomp($dfrom = substr($_,6);) last; } } if ( $dfrom && $from ne $dfrom ) { seek(STDIN,0,0); ... save copy and log ... } seek(STDIN,0,0); ... Clamav call by stream ... if ( ... virus found ... ) { ... warn mail ... exit; } seek(STDIN,0,0); open(AS, "| ... anti spam binary") or die " ... error string "; syswrite(AS, $buf) while ( read(STDIN, $buf, 32768) ); close(AS); }
It don't work if called with cat filter.pl | ./filter.pl or input from keyboard.
--
Marco Antonio
Rio-PM
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Recirect data and Filehandle manipulation (STDIN x Disk IO)
by Tanktalus (Canon) on Jun 30, 2005 at 21:18 UTC | |
by mda2 (Hermit) on Jul 01, 2005 at 15:13 UTC | |
by Tanktalus (Canon) on Jul 01, 2005 at 17:53 UTC | |
by mda2 (Hermit) on Jul 01, 2005 at 19:38 UTC | |
by mda2 (Hermit) on Jul 01, 2005 at 22:44 UTC |
Back to
Seekers of Perl Wisdom