[Help] Having a AGI problem getting info BACK from script

Hi there. I’m trying to build an app to let users see if thier LDAP account is locked out via telephone. I’m using Perl and the script runs great. When I run it outside of Asterisk it just says “Say Digits 123” when it gets to the AGI SayDigits line. BUt the AGI never returns anything to Asterisk. I’m fairly new to asterisk, so I might be making a sophmore error here, but I’m stumped… Thanks much…

AGI Debug Log: (Notice there are no AGI RX >> lines

-- Executing Goto("IAX2/2162-7", "custom-help|s|1") in new stack -- Goto (custom-helpdesk,s,1) -- Executing SayDigits("IAX2/2162-7", "1") in new stack -- Playing 'digits/1' (language 'en') -- Executing AGI("IAX2/2162-7", "adsearch.pl") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/adsearch.pl AGI Tx >> agi_request: adsearch.pl AGI Tx >> agi_channel: IAX2/2162-7 AGI Tx >> agi_language: en AGI Tx >> agi_type: IAX2 AGI Tx >> agi_uniqueid: 1153403795.7 AGI Tx >> agi_callerid: 2162 AGI Tx >> agi_calleridname: Dave Kolberg AGI Tx >> agi_callingpres: 1 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: 7777 AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: custom-helpdesk AGI Tx >> agi_extension: s AGI Tx >> agi_priority: 2 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: AGI Tx >> -- AGI Script adsearch.pl completed, returning 0 -- Executing SayDigits("IAX2/2162-7", "2") in new stack -- Playing 'digits/2' (language 'en') -- Hungup 'IAX2/2162-7'

The PL script

[code][root@asterisk1 agi-bin]# cat adsearch.pl

use strict;
use Net::LDAP;
use Asterisk::AGI;

my $ad = Net::LDAP->new(“ldap://myDC”)
or die “Could not connect”;

$AGI = new Asterisk::AGI;
$ad->bind("users@mydomain.com", password=>“secret”);
my $searchbase = “OU=All_Users,DC=mydomain,DC=com”;
my $filter = “memberof=CN=WIN,OU=All_Groups,DC=mydomain,DC=com”;
my $attrs = “sn”;
print “Searching…”;
my $results =$ad->search(base=>$searchbase,filter=>$filter,attrs=>$attrs);
my $count = $results->count;
$AGI->verbose(“Trying to say $count/n”,1);
$AGI->exec(‘Say Number’,$count);

The custom call:

[custom-help] exten => s,1,SayDigits(1) exten => s,2,agi(adsearch.pl) exten => s,3,SayDigits(2)[/quote]

die "Could not connect"
print “Searching…”;

You cannot print directly to the stdout because the stdout here is
Asterisk AGI interpreter which accepts only AGI commands.

You have to use verbose method instead.

it’s not just the space you have between Say and Number at the end of the AGI is it ??

Ok, those both helped. Thanks!

I think I’m just about there. It still isn’t saying the number, but I think it might just be a timing / wait issue.

What does the Result= -2 mean?

[quote]AGI Tx >> CLI>
AGI Rx << VERBOSE “Trying to say 196/n” 1
adsearch.pl: Trying to say 196/n
AGI Tx >> 200 result=1
AGI Rx << EXEC Say Number 196/n
– AGI Script Executing Application: (Say) Options: (Number)
AGI Tx >> 200 result=-2
– AGI Script adsearch.pl completed, returning 0

Found it! The /n was part of the problem. Also needed some quotes.


As a side, I took out the

use strict;

which seemed to be causing some problems.

Thanks for the help all!