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";
}
------------------
This may or may not help, but put 'demo1' in ticks. Also, as I read
this,
you're just testing extension 11?
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Azher Mughal
Sent: Tuesday, May 19, 2009 10:07 PM
To: asterisk-users at lists.digium.com
Subject: [asterisk-users] Manager ExtensionState function
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";
}
------------------
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Azher Mughal schrieb:> 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).Just to be sure: Did you define "hints" for the extensions? Philipp Kempgen -- AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de Gesch?ftsf?hrer: Stefan Wintermeyer, Handelsregister: Neuwied B14998 Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de Videos of the AMOOCON VoIP conference 2009 -> http://www.amoocon.de --
Seemingly Similar Threads
- why $cdr{'CALLERID'} and $cdr{'DNID'} are empty in perl agi connected with asterisk manager
- how to connect to asterisk via perl agi
- make: expand.c:489: allocated_variable_append: Assertion `current_variable_set_list->next != 0' failed.
- using AMI and Telnet to place calls
- AMI Originate issue