好的,所以我有一个ruby脚本,它从FM Server中获取一些数据并返回一个元组 . 我不得不这样做,因为我所知道的没有好的perl FM模块 .
[test.pl]
$ret = `ruby /root/rfm-query.rb $cid`;
@extens = split(/,/, $ret, 2);
print "DIAL SIP/$extens[0]";
因此,当我运行它时,它将按预期打印“DIAL SIP / 215”,但是当在Asterisk AGI脚本中使用相同的代码并使用$ extens [0]时,它总是不返回任何内容 .
#!/usr/bin/env perl
use Asterisk::AGI;
$|=1;
$AGI = new Asterisk::AGI;
%input = $AGI->ReadParse();
$cid = substr $input{'callerid'}, 1;
$cid =~ s/\+//g;
$ret = `ruby /root/rfm-query.rb $cid`; #rets nothing
@extens = split(/,/, $ret, 2);
$AGI->exec("DIAL SIP/$extens[0]");
为什么它在测试脚本中有效但在AGI中无效?
1 回答
我'm not sure what an Asterix AGI script is, but if its anything like CGI, where your code is being run by a server, then its probably running as a different user as you. Hopefully it is and not root and it probably can'读了
/root/rfm-query.rb
.您可以通过尝试打开并打印文件进行阅读来检查 .
(如果您正在以root身份开发和测试代码,也会感到羞耻 . )