Re: [exim] Get the value of an external script in a conditio…

Top Page
Delete this message
Reply to this message
Author: Andrew C Aitchison
Date:  
To: exim-users, mueller
Subject: Re: [exim] Get the value of an external script in a condition

>From the documentation that Jeremy quoted, I think that your script

should use "exit 0" and "exit 1" (or other non-zero value).
Your exim config snippet does not use $value in the match;
you need to do that or do the match in your script and use exit 0 *only
if there is a match*.

Interesting idea to use the whois database to detect spammers.
Since whois data has expiry info and doesn't change every day,
I wonder how easy it would be to cache the results.

whois isn't as easy to script as you may wish (Tony Finch
has a rant about this at
     https://fanf.dreamwidth.org/113367.html
) but it may be sufficient for your use.


On Tue, 20 Feb 2018, Mueller via Exim-users wrote:

> So when I run Exim in verbose. It turns out the expansion is working, but
> nervertheless it points to false but it should be true?:
>
>
> 13:54:04  9383 processing "defer"
> 13:54:04  9383 expanding: run{/etc/exim/panama  $sender_address_domain
> 13:54:04  9383    result: run{/etc/exim/panama  timerunr.com
> 13:54:04  9383 expanding: NameCheap <-------------------------------------
> 13:54:04  9383    result: NameCheap
> <---------------------------------------
> 13:54:04  9383 condition: match{run{/etc/exim/panama
> $sender_address_domain}{NameCheap}
> 13:54:04  9383    result: false
> 13:54:04  9383 expanding: true
> 13:54:04  9383    result: true
> 13:54:04  9383 skipping: result is not used
> 13:54:04  9383 expanding: false
> 13:54:04  9383    result: false
> 13:54:04  9383 expanding: ${if match{run{/etc/exim/panama
> $sender_address_domain}{NameCheap}{true}{false}}
> 13:54:04  9383    result: false
> 13:54:04  9383 check condition = ${if match{run{/etc/exim/panama
> $sender_address_domain}{NameCheap}{true}{false}}
> 13:54:04  9383                 = false
> 13:54:04  9383 defer: condition test failed

>
> So what is going wrong ?
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Jeremy Harris via Exim-users [mailto:exim-users@exim.org]
> Gesendet: Dienstag, 20. Februar 2018 10:35
> An: exim-users@???
> Betreff: Re: [exim] Get the value of an external script in a condition
>
> On 20/02/18 09:15, Mueller via Exim-users wrote:
>> #!/bin/bash
>> out=$(/usr/bin/whois $1|grep "Registrar:"| cut -d ':' -f2| awk '{print
>> $1}') echo "$out"
>>
>> I tried it with the $run command, but it uis always set to false!
>>
>> defer condition= ${if match{run{/etc/exim/panama
>> $sender_address_domain}{NameCheap}{true}{false}}
>
> The docs say:
>
> "If the command succeeds (gives a zero return code) <string1> is expanded
> and replaces the entire item; during this expansion, the standard
> output/error from the command is in the variable $value. If the command
> fails, <string2>, if present, is expanded and used."
> --
> Jeremy
>
> --
> ## List details at https://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>
>
> --
> ## List details at https://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/
>