Including agi files

Hello,

Is it possible to include an agi file in another one and call functions from it which execute as part of the agi file it is being called from ?
If yes, how to include one agi in another ?

Thank You.

We did libraries which we use in many AGI files.
I think this is best way.
Depends what you use - executables, scripts…

Thanks for the reply bira. What i want is to include an agi script written in perl in another agi script . The script to be included would contain functions involving agi code. Can i use the require statement to include agi files , the way we include normal perl files ?

Thank You.

Yes, you can.
If you need AGI - then
$AGI = Asterisk::AGI;#in your included file
But of course you must not call in included file
my %input = $AGI->ReadParse();
By the way - work with Perl only AGI’s :smiley:

Something like this will do it;

use DBI;
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
exit unless $input{‘request’};
$SIG{HUP} = ‘ignore_hup’;

require ("/etc/asterisk/agi-bin/common.inc");

and you will be able to use AGI functions from within common.inc
without previously calling anything.