[asterisk-users] Passing parameter from executable program to asterisk dialplan

Muro, Sam research at businesstz.com
Sun Jul 25 11:57:48 CDT 2010


Steve Edwards wrote:
>>> On Sun, 25 Jul 2010, Muro, Sam wrote:
>>>
>>>> I am having a problem understanding the way to retrieve some
>>>> parameters to asterisk via AGI or what ever method that fits. I have
>>>> an executable program that accept one parameter (CALLERID) and return
>>>> customer status from the database server which can be printed in the
>>>> console.
>>>>
>>>> #./retrive 0117473789
>>>> NAME: Franklin John
>>>> STATUS: Active
>>>>
>>>> Can someone advice on how i can catch this values from AGI or directly
>>>> on dialplan.
>
>> Steve Edwards wrote:
>
>>> AGI is a protocol used to interact with Asterisk. An AGI is a separate
>>> process created by Asterisk when you execute "agi()" in the dialplan.
>>>
>>> From best to worst...
>>>
>>> 1) You could recode your retrieve application so it uses the AGI
>>> protocol. Then, you could set channel variables to make these values
>>> accessible to the rest of your dialplan.
>>>
>>> 2) You could cobble up an AGI to execute your retrieve application
>>> using a "pipe" ("popen()" in c), parse the output and set channel
>>> variables.
>>>
>>> 3) You could cobble up something to execute your retrieve application,
>>> redirecting the output to a file and then use the FILE function read
>>> the text file and then parse the output using dialplan functions.
>
> On Sun, 25 Jul 2010, Muro, Sam wrote:
>
>> Option one and two looks more ideal. Let stick on option one, the
>> program is written in C++ (Actually is a corba interface). I have tried
>> looking on how to write AGI script using C++ in vain. I am used to
>> perl/php for scripting.. Can you post a snippet of c++ agi script.
>
> I'm a c weenie myself. I coded my own library way too long ago and
> remember the scars :)
>
> If you google for "asterisk agi c++ library" you'll find links to cagi,
> quivr, and probably a couple more. I don't know if any are c++ specific.
>
> The basic "outline" is:
>
>  	call a function to read the AGI environment from stdin. (Mine is
>  	named "agi_read_environment()")
>
>  	get your customer ID number either from the command line or from a
>  	channel variable. (argv[] or "agi_get_variable("CUSTOMER-ID",
>  	customer_id".)
>
>  	retrieve your values from your database.
>
>  	set your channel variables. ("agi_set_variable("CUSTOMER-NAME",
>  	mysql_row[CUSTOMER_NAME])")
>
> --
Thanks Steve

Let me check them out and give them a try. I really appreciate your input

Sam



More information about the asterisk-users mailing list