[asterisk-users] Get dialed numbers in AGI

Ralph Liebessohn ralphliebessohn at gmail.com
Fri Jan 12 03:29:47 MST 2007


On 1/11/07, Eric ManxPower Wieling <eric at fnords.org> wrote:
>
> Steve Edwards wrote:
> > On Thu, 11 Jan 2007, Yuan LIU wrote:
> >
> >> AGI doesn't see the name "var"; all it sees is an array @ARGV (or
> >> whatever in the respective language).  As the documentation says,
> >> values are passed like command line arguments.
> >
> > But, in the interest of "more maintainable code," you can pass the
> > option name and use "getopt_long()" in "C" or whatever language you use.
> > For example,
> >
> >     agi(block-ani,--ani=555555555,--dnis=8005551212,--debug,--verbose)
> >
> > vs
> >
> >     agi(block-ani|555555555|8005551212|y|y)
>
> AGI() does not support more than 1 parameter to AGIs.
>
>
# cat extensions.conf
exten => 8899,1,Read(my_var|sound-file|5|||15)
exten =>
8899,2,AGI(/usr/share/asterisk/bin/firstagi.php|${my_var}|123|321|111|222)

# cat firstagi.php
$my_var=$argv[1];
fwrite(STDOUT,"exec sayalpha $my_var \n");
fflush(STDOUT);
$my_var=$argv[2];
fwrite(STDOUT,"exec sayalpha $my_var \n");
fflush(STDOUT);
$my_var=$argv[3];
fwrite(STDOUT,"exec sayalpha $my_var \n");
fflush(STDOUT);
$my_var=$argv[4];
fwrite(STDOUT,"exec sayalpha $my_var \n");
fflush(STDOUT);
$my_var=$argv[5];
fwrite(STDOUT,"exec sayalpha $my_var \n");
fflush(STDOUT);

Results in console:
-- AGI Script Executing Application: (sayalpha) Options: (98765) // Result
of READ
    -- AGI Script Executing Application: (sayalpha) Options: (123) // Other
parameters
    -- AGI Script Executing Application: (sayalpha) Options: (321)
    -- AGI Script Executing Application: (sayalpha) Options: (111)
    -- AGI Script Executing Application: (sayalpha) Options: (222)


AGI receives more than 1 parameter.

-- 
Ralph Liebessohn
ICQ: 74835911
Skype: liebessohn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070112/cc40025a/attachment.htm


More information about the asterisk-users mailing list