L
L
L_V_S2014-10-31 15:29:46
Perl
L_V_S, 2014-10-31 15:29:46

How to determine if an AGI script is connected to asterisk?

I'm trying to connect the script to the diaplane in the asterisk in order to shorten the extensions.conf config
, but I don't understand how to find out if the script is running, I
connect it as follows, the script itself is in the folder /var/lib/asterisk/cgi-bin/
exten=> s,1,AGI(incoming .agi)
is this how it is understood that it worked, for example with errors or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2014-10-31
@rostel

you can throw NOOP
with asterisk-perl comes down to one line:
$AGI->noop("Start");

P
pcdesign, 2014-11-02
@pcdesign

here is how it is understood that it worked, for example with errors or not
Turn on logging inside your script.
On the knee, for example:

open my $file, '>  /tmp/my-agi.log';
print $file "Скрипт запустился";

And so on, at the beginning at the end, in the middle of the script.
Write down the values ​​of the variables there, the data that you receive from AGI and what you do with them there.
Everything is written in text.
It will be clear how it works.
Or use a ready-made logging module, such as Log::Log4perl.
It's even more comfortable with him.
Here is a piece from my code:
use Data::Dumper;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init( { level => $ON, file => ">>/var/lib/asterisk/agi-bin/test.log" } );

DEBUG "START";

my $AGI   = new Asterisk::AGI;
my %input = $AGI->ReadParse();

DEBUG "cid" . Dumper($AGI);

When you are convinced that the script works as it should, then simply turn off logging level => $OFF.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question