Hello!
On Tue, Jul 23, 2013 at 5:27 AM, Water Duan wrote:
> 求教问题出在哪里? 代码如下:
>
> nginx.conf
> body_filter_by_lua_file conf/a.lua;
>
> cat /tmp/a.lua
> #################
> local response = ngx.arg[1]
> local handle = io.popen(("sh /tmp/a.sh %s"):format(response))
显然,你这里需要对 shell 命令的参数进行 quote, 因为你的 response
数据中可能含有空格。比如可以使用单引号(但你要小心数据中可能会有单引号):
sh /tmp/a.sh '%s'
另外,你要确认你的 nginx worker 进程所使用的系统帐户(经常是 nobody 这样的帐户)拥有足够的权限(比如读取
/tmp/a.sh 文件的权限)。
一般地,你可以在 nginx 的错误日志文件中看到相关的错误消息(如果有的话)。
Regards,
-agentzh