procmail
[Top] [All Lists]

Re: filtering headers

1997-11-05 14:31:53
I keep fiddling with this, but I can't seem to get it.  I am grateful to
those that pointed me in the right direction, even though there were minor
syntax errors (which I've probably made worse by my fiddling).

So what's wrong with my latest try (below)?

# Discard some useless headers
:0fhw
| formail -Y -IResent-Date:               \ 
             -IIn-Reply-To:               \ 
             -IResent-Message-Id:         \ 
             -IContent-Type:              \ 
             -IX-My-Info:                 \ 
             -IReferences:                \ 
             -IX-Sender:                  \ 
             -IX-No-Archive:              \ 
             -IContent-Transfer-Encoding: \ 
             -IDelivered-To:              \ 
             -IMime-Version:              \ 
             -IX-Mailing-List:   

# discard our internal routing
:0 fhw
|perl  -ne 'if(/^\s/) {'                   \
        -e '    $h .= $_;'                 \
        -e '} else {'                      \
        -e '    if($h =~ /^Received:/) {'  \
        -e '        print $h unless $saw;' \
        -e '        $saw=1 if $h =~ /gw1.hughes-defense-comm.com/;' \
        -e '    } else {'                  \
        -e '        print $h;'             \
        -e '    }'                         \
        -e '    $h = $_;'                  \
        -e '  }'                           \
        -e '}'

If it isn't obvious, here's that resulting log:

Usage: formail [-bczfrktqY] [-D nnn idcache] [-p prefix] [-l folder]
        [-xXaAiIuU field] [-R ofield nfield]
   Or: formail [+nnn] [-nnn] [-bczfrktedqBY] [-D nnn idcache] [-p prefix]
        [-n [nnn]] [-m nnn] [-l folder] [-xXaAiIuU field] [-R ofield nfield]
        -s [prg [arg ...]]
procmail: Program failure (64) of "formail"
procmail: Rescue of unfiltered data succeeded
procmail: Skipped "-IIn-Reply-To:               \ "
procmail: Skipped "-IResent-Me...[snip]...sion:      \ "
procmail: Skipped "-IX-Mailing-List:   "
Unmatched right bracket at -e line 12, at end of line
syntax error at -e line 12, near ";}"
Execution of -e aborted due to compilation errors.
procmail: Program failure (2) of "perl  -ne 'if(/^\s/) {'                   \
        -e '    $h .= $_;'                 \
        -e '} else {'                      \
        -e '    if($h =~ /^Received:/) {'  \
        -e '        print $h unless $saw;' \
        -e '        $saw=1 if $h =~ /gw1.hughes-defense-comm.com/;' \
        -e '    } else {'                  \
        -e '        print $h;'             \
        -e '    }'                         \
        -e '    $h = $_;'                  \
        -e '  }'                           \
        -e '}'"
procmail: Rescue of unfiltered data succeeded

<Prev in Thread] Current Thread [Next in Thread>