FW: [asterisk-users] Get dialed numbers in AGI

Mike D'Ambrogia miked at jamagination.com
Fri Jan 12 10:55:23 MST 2007


Ralph
 
Morning - no, what I meant was that *I* was kind of new to * and I'm
learning AGI while working thru my first AGI script too
 
Let me see if I can explain my point better this time, it was a pretty
weak attempt below.  
 
The key point is that the $argv[] array variables are only available at
the initial AGI script startup.  The first time you call the AGI script
from the dialplan any params passed in would be exposed in $argv[].  
 
In the script snippet that I found and included with the email that I
sent below it appeared to me that you did the following:
 
from the dialplan call the AGI script and pass in a variable
from within the AGI script you <did some stuff>
while within the AGI script you did this:
 
fwrite(STDOUT,"exec Read my_var|/sound_to_play|5|||15 \n");
 
since:
1 - this command from the AGI is being passed back in to * while the AGI
script is running in a manner akin to a shell or child process (I don't
think that is actually a child, but conceptually it might help to think
of it this way for the purpose of this example)
2 - the script does not stop and then restart
3 - $argv can only be populated at script startup
4 - $argv cannot be populated with a new value in this way since there
is no restart
 
in the dialplan snippet above my_var can only come back in thru $argv[]
 
This is my theory only, I have not tested this
 
Others have made mention that the phpAGI class might be helpful to
achieve your goal, while I have not looked into phpAGI I'd think that it
would too.  Native php AGI scripting seems to be pretty primitive (but
its great to have it there).  
 
md
 
 
 
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Ralph
Liebessohn
Sent: Friday, January 12, 2007 2:13 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: FW: [asterisk-users] Get dialed numbers in AGI



On 1/11/07, Mike D'Ambrogia <miked at jamagination.com> wrote: 


Ralph
 
Kind of new to asterisk, and really new to AGI but it looks like you
were trying to have the AGI script tell asterisk to read and lay the
results into my_var and then regain control in the AGI script, is that
correct?
 
If so I don't think that will work since the dialplan variables are only
exposed/visible when you start the AGI script, since you are still
within the AGI script you'll probably never see my_var if called this
way
 
md


Mike,

that's my first agi. Easy to see, ahm?
What I'm thinking to do is, play a sound, get the numbers dialed, see on
a db what to do using the dialed numbers, get back to dialplan (go to a
queue or something else). 
The way started to work is that you said, send dialed as parameter to
agi and get it with $argv[1]. And I was trying to get it from stdin.
Things I do not understand well and the documentations I've read are not
so clear are the way agi work with some things like: 
- How can I fix this agi to work?

AGI Rx << exec read my_var|sound-file|5|||15
    -- AGI Script Executing Application: (read) Options:
(my_var|sound-file|5|||15) 
    -- Accepting a maximum of 5 digits.
    -- Playing 'sound-file' (language 'en')
    -- User entered '85214'
AGI Tx >> 200 result=0 
AGI Rx << get variable my_var
AGI Tx >> 200 result=1 (85214)
AGI Rx << exec saydigits Resource id #1   // (this is the result of
my_var)

All the variables here was my_var, it worked for GET VARIABLE but didn't
for SAYDIGITS and odbc connection. How can I SAYDIGITS of my_var or
insert my_var value into a db?

- What I need more to use WAIT FOR DIGIT? Because it didn't stop to wait
for digits. 
- STDIN shoudn't get the result of READ or GET VARIABLE? Where these
values go?

-- 
Ralph Liebessohn
ICQ: 74835911
Skype: liebessohn 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070112/2f6bb6cd/attachment.htm


More information about the asterisk-users mailing list