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

2007-01-12 Thread Ralph Liebessohn

On 1/11/07, Mike D'Ambrogia [EMAIL PROTECTED] 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
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2007-01-12 Thread Time Bandit

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?

For AGI in PHP I always use this : http://phpagi.sourceforge.net/

Would make your life easier

hth
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2007-01-12 Thread Mike D'Ambrogia
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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 

___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2007-01-12 Thread Mike D'Ambrogia
just as a followup and potential solution to the passing of values, I've
been setting variables at the top of the dialplan using :
 
exten = 100,n,Set(my_var=SomeValue)
 
Now I can modify my_var in the dialplan, and I can get/set my_var in the
AGI script via GET VARIABLE and SET VARIABLE
 
You'll need to modify your current overall programming strategy in order
to implement this.  But do the READ that you are attempting from within
the dial plan and not the AGI script, and either update my_var prior to
calling the AGI, or pass my_var in to the AGI as a param.  
 
I've been calling my AGI with an extra param that helps the script
determine where I am in the logic, i.e. if I pass in the extra param
with a -1 then I'm at the beginning of the logic, if I pass in a -2 then
I know that I've got the variables available and set so that I can do my
mysql inserts, etc.  On the AGI side I trap the value of the extra param
in a switch stmt and then execute the approp block of code based on the
value.
 
md
___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2007-01-12 Thread Yuan LIU

From: Ralph Liebessohn [EMAIL PROTECTED]

On 1/11/07, Mike D'Ambrogia [EMAIL PROTECTED] 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?


Ralph,

Is there a special reason you need to Read() from inside AGI?  If not, the 
following should work:


--- snippet from extensions.conf
exten = s,1,Read(my_var|sound-file|5|||15)
exten = s,2,AGI(MyAGI,${my_var})
--- snippet ends

--- snippet from MyAGI
$conn=odbc_connect('MSSQL', 'USER', 'PASS');
$query = odbc_exec($conn, INSERT INTO dialed(number) VALUES('$argv[1]'));
fwrite(STDOUT,exec saydigits $argv[1] \n);
--- snippet ends

Yuan Liu


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



___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2007-01-12 Thread Yuan LIU

From: Mike D'Ambrogia [EMAIL PROTECTED]

You'll need to modify your current overall programming strategy in order
to implement this.  But do the READ that you are attempting from within
the dial plan and not the AGI script, and either update my_var prior to
calling the AGI, or pass my_var in to the AGI as a param.


Totally.


I've been calling my AGI with an extra param that helps the script
determine where I am in the logic, i.e. if I pass in the extra param
with a -1 then I'm at the beginning of the logic, if I pass in a -2 then
I know that I've got the variables available and set so that I can do my
mysql inserts, etc.  On the AGI side I trap the value of the extra param
in a switch stmt and then execute the approp block of code based on the
value.

md


This may not be necessary, as AGI receives the calling dialplan's context, 
extension, and priority via AGI environment (same way as CGI).  So if you 
plan ahead, your script should be able to determine where in the flow it is 
being called.


Yuan Liu


___
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users