Re: [exim] Testing system filter w/ multiple recipients

Góra strony
Delete this message
Reply to this message
Autor: Bill Hacker
Data:  
Dla: exim-users
Temat: Re: [exim] Testing system filter w/ multiple recipients
Michael F. Sprague wrote:

> Bill Hacker <wbh@???> wrote:
>
>>Michael F. Sprague wrote:
>>
>>>Hi folks,
>>>
>>>Is there any way to test a system filter on the command line with multiple
>>>recipients? For example:
>>>
>>>exim -f testuser@??? -bfd example2.com -bfl user -bF
>>>system_filter \
>>> < test.message
>>>
>>>works just fine.
>>>
>>>But I'd like to see how my filter works with I have > 1 recipient. I
>>>cannot
>>>find anything in the docs or a search of archives about this. Any advice
>>>is
>>>appreciated.
>>
>>Have you tried replacing 'test.message' with a directory populated with
>>'many' test message files?
>>
>>Bill Hacker
>
>
> No, but would that do the trick? According to the docs, exim will obtain the
> envelope recipient is set either by the username of the logged in user (the
> default) or via the -bfl/-bfd switches. Are you saying that if a directory
> is full of several copies of 'test.message' but each with a different 'To:'
> header, exim would see this as several recipients for the same message?
>
> Thanks,.
> mikeS
>


I *presumed* from the man age statement that it took its input from
stdin, that one coudl pipe or reditect a file into place.
Didn't work for me.

This should work:

(without getting into various favorite UNIX editors):

In the spreadsheet of your choice, create three columns:
- put into column one:   exim -f
- leave column two empty:
- put into column three:    -bfd example2.com -bfl user -bF 
system_filter < test.message &&


Select that row and do a 'fill down' limited to however many users you
will wish to test.

Now copy your selected user list and paste it into column two.

Save/export as either fixed-position, tab-separated-variable, or
comma-separated variable.

If .csv or .tsv, then hit the output file with a text editor and:

- insert a first line:

#!/bin/sh

- replace the commas or tabs with spaces.

result should look like this:

#!/bin/sh
exim -f recipient1@??? -bfd example2.com -bfl user -bF
system_filter < test.message &&
exim -f recipient2@??? -bfd example2.com -bfl user -bF
system_filter < test.message &&
.
. (many lines)
.
.
exim -f recipient(n)@example(n).com -bfd example2.com -bfl user -bF
system_filter < test.message &&

Save it as, for example, 'test_filter1.sh'

scp it to your server.

Invoke it with, for example: 'sh test_filter1.sh <Enter>'

The '&&' will feed each line as the previous line completes successful
execution, a single '&' will not wait for that.

May not be as 'elegant' as hacking code but probably faster and more
predictable to implement.

Tested on a production server with three 'live' addresses and an empty
file for system_filter, and it works for me (FreeBSD 4.11, Exim 4.43, bash)

You can vary example2.com, user, filter to be tested, and test message
in a similar manner, and keep several such scripts handy for future
minor modification and other tests.

HTH,

Bill Hacker