[asterisk-users] Manager ExtensionState function

Azher Mughal azher at hep.caltech.edu
Tue May 19 22:06:58 CDT 2009


Hi,

I am trying to get the extension status (weather it has dialed
outgoing call via SIP or IAX2), using the following piece of code
however it always returns -1 on all the extensions (valid/invalid).

Am i missing something ? Any help.

Thanks

-----------------------------------
#!/usr/bin/perl

use Asterisk::Manager;
use lib './lib', '../lib';
$|++;

my $astman = new Asterisk::Manager;

$astman->user('mark');
$astman->secret('mark');
$astman->host('127.0.0.1');

$astman->connect || die $astman->error . "\n";

$astman->setcallback('Hangup', \&hangup_callback);
$astman->setcallback('DEFAULT', \&default_callback);

my %out = $astman->sendcommand(
                                     Action => 'ExtensionState',
                                     Context => demo1,
                                     Exten => 11,
                                     ActionID => 1,
                                    );
if( $out{'Status'} )
{
        print STDERR "Extension Status $out{'Status'}\n";
}


$astman->disconnect;

sub hangup_callback {
        print STDERR "hangup callback\n";
}

sub default_callback {
        my (%stuff) = @_;
        foreach (keys %stuff) {
                print STDERR "$_: ". $stuff{$_} . "\n";
        }
        print STDERR "\n";
}
------------------




More information about the asterisk-users mailing list