Asterisk 12 and Perl AGI script not working

I have a simple Perl AGI script that gets called via context on FreePBX Asterisk 12.6.0. It gets called fine, but it does not execute anything.

This script works on FreePBX running Asterisk 1.8.12.0.
Here is the stripped down script:

#!/usr/bin/perl
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $dnid = $input{‘dnid’};
$AGI->noop('------------------------- CHKRT AGI Called - DNID = ’ . $dnid);
exit(0);

I have a simple context with a NoOp “Running AGI” before and “AGI Complete” after.
Here is the output on the Asterisk 12 server that doesn’t work

> -- Executing [s@from-trunk:2] NoOp("SIP/VOIP-00000014", ""Running AGI"") in new stack
-- Executing [s@from-trunk:3] AGI("SIP/VOIP-00000014", ""/var/lib/asterisk/agi-bin/chkrt.agi"") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/customIncoming/chkrt.agi

<SIP/VOIP-00000014>AGI Tx >> agi_request: /var/lib/asterisk/agi-bin/chkrt.agi
<SIP/VOIP-00000014>AGI Tx >> agi_channel: SIP/VOIP-00000014
<SIP/VOIP-00000014>AGI Tx >> agi_language: en
<SIP/VOIP-00000014>AGI Tx >> agi_type: SIP
<SIP/VOIP-00000014>AGI Tx >> agi_uniqueid: 1435071361.1111
<SIP/VOIP-00000014>AGI Tx >> agi_version: 12.6.0
<SIP/VOIP-00000014>AGI Tx >> agi_callerid: 8550000000
<SIP/VOIP-00000014>AGI Tx >> agi_calleridname: 8550000000
<SIP/VOIP-00000014>AGI Tx >> agi_callingpres: 0
<SIP/VOIP-00000014>AGI Tx >> agi_callingani2: 0
<SIP/VOIP-00000014>AGI Tx >> agi_callington: 0
<SIP/VOIP-00000014>AGI Tx >> agi_callingtns: 0
<SIP/VOIP-00000014>AGI Tx >> agi_dnid: 3012325784
<SIP/VOIP-00000014>AGI Tx >> agi_rdnis: unknown
<SIP/VOIP-00000014>AGI Tx >> agi_context: from-trunk
<SIP/VOIP-00000014>AGI Tx >> agi_extension: s
<SIP/VOIP-00000014>AGI Tx >> agi_priority: 3
<SIP/VOIP-00000014>AGI Tx >> agi_enhanced: 0.0
<SIP/VOIP-00000014>AGI Tx >> agi_accountcode:
<SIP/VOIP-00000014>AGI Tx >> agi_threadid: 139993973966592
<SIP/VOIP-00000014>AGI Tx >>
– <SIP/VOIP-00000014>AGI Script /var/lib/asterisk/agi-bin/chkrt.agi completed, returning 0
– Executing [s@from-trunk:4] NoOp(“SIP/VOIP-00000014”, ““AGI Complete””) in new stack

Did AGI change with Asterisk 12? I can’t seem to find anything that references script changes.
Thank you for any assistance !
PB

I can’t help you with this but there have been a TON of changes between 1.8 and 11/12/13. I also know that 12 isn’t really worth spending time on; go to 11 or 13 (these are LTS versions).

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/AGI-communication.html

Your script appears to be running but you don’t say what it is supposed to do nor wheteher it did it or not , that link has a whole bunch of SET * commands that affect the channel variables, but there is a whole SL more that AGI can do, sandwich your agi script call between calls to DUMPCHAN() to see the effect and don’t neglect all the command available in the asterisk cli that start with agi (tab-complete) you should explore while debugging but there are no mind readers here :wink:

Overkill - I’ll go to 13 - thanks man.

dicko - the script I posted (in it’s entirety) is quite simple. It gets the DNID and NoOps it out.

And it doesn’t work (looking at the output). The question is “Why?” when it obviously should work.

Nothing that requires mind reading. :smile:

If you have the right permissions and everything that script should have returned (with agi set debug on )
.
.
[2015/07/02 10:45:47] <DAHDI/i1/1234-a>AGI Tx >>
[2015/07/02 10:45:47] <DAHDI/i1/1234-a>AGI Rx << NOOP ------------------------- CHKRT AGI Called - DNID = 1234556678897
[2015/07/02 10:45:47] <DAHDI/i1/1234-a>AGI Tx >> 200 result=0
.

Check your permissions and any inadvertent stdout/stdin redirection you might have, AGI uses those devices to communicate with Asterisk.

IWFM

rasterisk -V
Asterisk 11.17.1

but the script per se does nothing but return the NOOP on stdout, is that all you want?

If you want to check your stdout at a perl level add

print “Some identifiable gibberish\n”;

to your script and you should see it in the cli.

(I also suggest you DON’T use Asterisk 12 as it only gets security fixes, I would use 11 as 13 is as yet not completely stable with FreePBX)

[edit]

relooking at your post you are calling the script wrong, it should be:-

agi(script,arg1,arg2. . .)

you are redirecting STDOUT by inappropriately “”""“quoting”"""" the call , google can expose your error, but the answer will be a little esoteric :slight_smile:

(How’s that for mindreading ? )