[asterisk-users] using AMI and Telnet to place calls

Danny Nicholas danny at debsinc.com
Thu Mar 1 13:31:09 CST 2012


Since you are using AMI, I would assume you are using one of the AMI
interfaces from CPAN or somewhere.  If this is the case you could do
something like this:

   my $astman = new Asterisk::Manager;

               $astman->user('mickey');

               $astman->secret('mouse');

               my $man_addr='192.168.23.172';

               my $man_ok=1;

               open (my $man_in, "/etc/asterisk/manager.conf") or
$man_ok=undef;

               if ($man_ok) {

                  while (<$man_in>) {

                     if ($_ =~ /^bindaddr/) {

                        (undef,$man_addr) = split /\=/, $_;

                        }

                     }

                  close $man_in;

                  }

               $man_addr =~ s/\s//g;

               ( $man_addr )=( $man_addr =~ /(.*)/ );

               $astman->host($man_addr);

               $astman->connect || die "Could not connect to " .
$astman->host . "!\n";

 

               my %resp = $astman->sendcommand(  Action => 'Originate',

                                                           Channel =>
$extval,

                                                           Variable =>
"ARG1=$fileval",

                                                           Exten => $extval,

                                                           Context =>
'playit',

                                                           priority => 1,

                                                           Number => 5551212

                                                           );

               sleep 2;

n  Do a while here to interrogate %resp

               %resp = $astman->sendcommand(  Action => 'Logoff');

 

              

 

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of John Millican
Sent: Thursday, March 01, 2012 12:07 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] using AMI and Telnet to place calls

 

Hello,
I am using a perl script to pull call info from a DB and place calls via
telnet and AMI, all on local machine of course.  My problem is that I need
to capture any response from the carier, such as this taht appears in the
CLI:
[Mar  1 12:55:50]   == Using SIP RTP CoS mark 5
[Mar  1 12:55:50]     -- Got SIP response 503 "No Circuit Available" back
from xxx.xxx.xxx.xxx:5060
[Mar  1 12:55:50]        > Channel SIP/<provider> was never answered
and be able to relate that back to the dialed number for that call.  Is this
possible? 
I am using async in the AMI command.   Do I need to do something such as
adding and event id to the AMI originate action then listen for response
from AMI?
Obviously I am a bit lost here.
Thanks for any pointers toward the solution.
JohnM 



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120301/23440a3d/attachment.htm>


More information about the asterisk-users mailing list