Re: [Exim] Need quick script written - should be easy

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Kevin Reed
Ημερομηνία:  
Προς: exim-users
Αντικείμενο: Re: [Exim] Need quick script written - should be easy
Marc Perkel said:
> I need a little script written to strip ads out of message bodies -
> starting with yahoo ads.
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotons.yahoo.com/design_giveaway/
>
> The script needs to be a pipe so that I pipe a message into it and it
> comes out the other end without the yahoo ad. Key on the line followed
> by "Do you Yahoo" on the next line and delete to next two lines
> following. 4 lines total to remove.


A quick an _dirty_ perl...

#!/usr/local/bin/perl

$BODY=0;
$WARN=0;

while(<STDIN>) {
    chop;


    # Look for header first and don't touch it
    if (length($_) ==  && ! $BODY) {
        $BODY=1;
        print "\n";
        next;
    }


    # If it is not the body, just print it
    if (!$BODY) {
        print $_ . "\n";
        next;
    }


    # If Body and we find a line (this is shorter in case they change it
    # We save the line and wait for the next to make sure
    if ( /_______________________/ ) {
        $line=$_;
        $WARN=1;
        next;
    }


    # if we found a line and we now find Do you Yahoo... we got it so
    # We eat up the full 4 lines and continue
    if ( $WARN && /Do you Yahoo!?/ ) {
        $WARN=0;
        <STDIN>;
        <STDIN>;
        next;
    }


    # If we found the line but didn't find Do you Yahoo... we got it
    # Line in error, so we send the line, and reset the warning
    if ( $WARN ) {
        print $line . "\n";
        $WARN=0;
    }


    # Just print the line
    print $_ . "\n";
}


I suspect you could do a similar thing with the system-filter and their a
packages that do the same like demime .

--
Kevin W. Reed - TNET Services, Inc.
Unoffical Exim MTA Info Forums - http://exim.got-there.com/forums