Linux
使用查詢程序重定向的路由器 - exim4
我們正在使用 配置
Exim4
路由器driver = queryprogram
,其想法是執行腳本並根據腳本的邏輯重定向某些地址。問題是在調試 exim 如何路由地址時,我們得到一個
my_router router: command returned non-zero code 127
錯誤。為什麼 exim 得到一個
command returned non-zero code 127
? 我們如何解決這個問題?謝謝!
這是一些-希望-有用的資訊:
# exim -d -bt anaddress@mylocaldomain.com ... --------> 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 anaddress@mylocaldomain.com: 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 anaddress@mylocaldomain.com message: my_router router: command returned non-zero code 127 anaddress@mylocaldomain.com 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.template
如下:... 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 行格式錯誤,就找不到合適的解釋器。
此外,我不確定您是否真的希望您的腳本由 PHP 解釋。所以可能你必須用
#!/bin/sh