exim,可变string扩展

我如何从前向文件获取本地域列表?

/etc/exim4/forwards一个例子:

 [email protected]: [email protected] # ignore this line [email protected]: [email protected] [email protected]: [email protected] 

这里的string扩展(或者称之为g )应该返回test.com : hugo.com

我认为这可以用readfilemap来完成,但是我无法得到它的工作。

我有些东西几乎像你想要的那样工作。 这个扩展做的是:

  1. 在文件中啜食,使用; 作为分隔符。
  2. 排除#中的任何行(即注释)。
  3. 应该跳过空行,但我的正则expression式不匹配,它仍然包含这些空行,所以我刚刚删除它,并在那里留下或{{} {}}块。
  4. 在每行之前提取项目,并从中提取该域。
  5. 把它全部列入清单。

我不认为这是你所需要的,但它显示了如何parsing和grep'd列表。

 CentOS58[root@ivwm41 exim]# more test_list.cf [email protected]: [email protected] # ignore this line [email protected]: [email protected] [email protected]: [email protected] CentOS58[root@ivwm41 exim]# exim -be '${reduce {<; ${readfile{/etc/exim/test_list.cf}{;}} } {} {${if or{ {match{$item}{#}} {match{$item}{#}} } {$value} {$value:${sg {${extract{1}{:}{$item}}} {^.*@}{} }}}}}' :test.com:test.com:hugo.com 

如果您将扩展逻辑分散到各个部分,则看起来像这样:

 exim -be '${reduce {<; ${readfile{/etc/exim/test_list.cf}{;}} } {} {${if or{ {match{$item}{#}} {match{$item}{#}} } {$value} {$value:${sg{${extract{1}{:}{$item}}} {^.*@} {}}}} } } ' 

还有一点需要解决的是领导:不应该在那里。 我不是100%肯定它为什么在那里: – 我真的没时间深入研究它。 需要对逻辑进行一点处理,以捕捉导致冒号出现的任何情况,然后结果应该是可以用作条件的域列表。