2
votes

Ok, so I have a ruby script that grabs some data from FM Server and returns a tuple. I had to do this because there's no good perl FM module that I'm aware of.

[test.pl]

$ret = `ruby /root/rfm-query.rb $cid`;
@extens = split(/,/, $ret, 2);
print "DIAL SIP/$extens[0]";

So when I run this it will print "DIAL SIP/215" as expected but when using the same code in an Asterisk AGI script and using $extens[0] it always returns nothing.

#!/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]");

Why does it work in a test script but not in an AGI?

1
Does Net::FileMaker do what you're looking for?cjm
I looked at Net::FileMaker and the documentation seems to suck. I'm not really sure if it does what I need or not.cstrouse
@mu Yes they are both being ran as the same user. I can't tell you what's in $? when it fails because I can't figure out how to get the AGI script to output text to the Asterisk console.cstrouse

1 Answers

2
votes

I'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't read /root/rfm-query.rb.

You can check this by trying to open and print the file for reading.

my $rfm_query_file = "/root/rfm-query.rb";
open my $fh, "<", $rfm_query_file or die "Cant open $rfm_query_file: $!";

(Also, shame on you if you're developing and testing code as root.)