路由器redirectqueryprogram – exim4

我们正在configuration一个driver = queryprogramExim4路由器,其思路是根据脚本的逻辑执行脚本并redirect某些地址。

问题是,当debuggingexim路由地址时,我们得到一个my_router router: command returned non-zero code 127错误。

为什么exim得到一个command returned non-zero code 127 ? 我们如何解决这个问题?

谢谢!

以下是一些有用的信息:

 # exim -d -bt [email protected] ... --------> my_router router <-------- local_part=anaddress domain=mylocaldomain checking local_parts anaddress in "! root"? yes (end of list) R: my debug message calling my_router router my_router router called for [email protected]: domain = mylocaldomain.com requires uid=1001 gid=1001 current_directory=/tmp direct command: argv[0] = /tmp/myscript.sh direct command after expansion: argv[0] = /tmp/myscript.sh my_router router: defer for [email protected] message: my_router router: command returned non-zero code 127 [email protected] cannot be resolved at this time: my_router router: command returned non-zero code 127 search_tidyup called >>>>>>>>>>>>>>>> Exim pid=8094 terminating with rc=1 >>>>>>>>>>>>>>>> 

处理邮件的脚本(/tmp/myscript.sh)只是

 #/usr/bin/php echo 'redirect another_address@another_domain.com'; exit; 

该脚本具有权限

 $ ls /tmp total 196K 4.0K -rwxrwxr-x 1 someuser somegroup 58 Oct 5 20:48 myscript.sh 

路由器在exim4.conf.templateconfiguration为:

 ... my_router: debug_print = "R: my debug message" driver = queryprogram command = /tmp/myscript.sh current_directory = /tmp command_user = myuser # domains = +local_domains local_parts = ! root cannot_route_message = Unknown Special user 

你在脚本中有一个拼写错误:在哈希之后,bang被忽略。

 #!/usr/bin/php echo 'redirect another_address@another_domain.com'; exit; 

退出代码127意味着只要shebang行格式错误,就不会find合适的解释程序。

另外我不确定你真的希望你的脚本被PHP解释。 所以可能你必须用#!/bin/shreplace第一行