I have been unable to capture user hangups with my AGI script. Instead of returning -1 or 0 and ‘hangup’, the script just seems to terminate. I have coded it two ways. In the first way I just made the calls and captured the return value. In the second way I used the Perl Asterisk::AGI module. I get the same behaviour each way. In the code below, it never seems to get to the HandleHangup subrouting. I never see anything come back on STDERR and I don’t get the file created either.
My extensions.conf file is pretty simple with just two real lines. The first calls the agi script using DeadAGI. The second one does a hangup when the script ends.
Here is the script that uses AGI Module.
#!/usr/bin/perl -w
use Asterisk::AGI;
use strict;
$|=1; #This makes the output stream rather than buffer
my %AGIVariables; #the hash I store the AGI default variables in
my $MyAGI = new Asterisk::AGI;
send callback reference
$MyAGI->setcallback(&HandleHangup);
$MyAGI->answer();
%AGIVariables=$MyAGI->ReadParse();
$MyAGI->record_file(’/tmp/CLibTest’,‘wav’,’#’,‘180000’,‘1’,‘10’);
sleep (5);
$MyAGI->stream_file(’/tmp/CLibTest’, ‘""’);
sub HandleHangup{
print STDERR “Got to handlehangup!!!\n”;
my $FlagFile=’/tmp/TestCLibFlagFile’;
my $now = time;
utime $now, $now, $FlagFile;
exit;
}
Any tips, hints, etc. would be greatly appreciated. Thanks.