Is there a limitation to the number of variables you can set from a PHP agi script? I have a simple example and I can't get it to let me set more than 1. I am pretty sure I am just missing something, but I've searched all over an can't find the answer. Here is the extensions.conf part: exten => _XXXXXXXXXX,1,AGI,diallocal.agi exten => _XXXXXXXXXX,n,NoOp(${ISLOCALCONTEXT}) exten => _XXXXXXXXXX,n,NoOp(${ISLOCALDID}) Here is the part from the agi that sets the variables: echo ' EXEC SetVar ISLOCALCONTEXT="'.$row['context'].'"'; echo ' EXEC SetVar ISLOCALDID="'.$row['did'].'"'; If I run it is as, ISLOCALCONTEXT gets set, but not ISLOCALDID: -- Executing NoOp("SIP/3333-081d2c38", "CONTEXT2") in new stack -- Executing NoOp("SIP/3333-081d2c38", "") in new stack If I flip their order in the agi, then ISLOCALDID gets set, but not ISLOCALCONTEXT: -- Executing NoOp("SIP/3333-081d8d78", "") in new stack -- Executing NoOp("SIP/3333-081d8d78", "4444") in new stack Any idea what I am missing? Only the first "exec setvar" gets run and the other one appears to just be ignored. I just want to be able to set 2-3 variables and then return to the dialplan. Please note that I do not want to use phpagi so don't tell me to use that, I want to figure out why it doesn't work this way.
On Thu, 4 Jun 2009, Peder wrote:> Is there a limitation to the number of variables you can set from a PHP agi > script? I have a simple example and I can't get it to let me set more than > 1. I am pretty sure I am just missing something, but I've searched all over > an can't find the answer. Here is the extensions.conf part: > > exten => _XXXXXXXXXX,1,AGI,diallocal.agi exten => > _XXXXXXXXXX,n,NoOp(${ISLOCALCONTEXT}) > exten => _XXXXXXXXXX,n,NoOp(${ISLOCALDID}) > > > Here is the part from the agi that sets the variables: > > echo ' EXEC SetVar ISLOCALCONTEXT="'.$row['context'].'"'; > echo ' EXEC SetVar ISLOCALDID="'.$row['did'].'"'; > > > If I run it is as, ISLOCALCONTEXT gets set, but not ISLOCALDID: > > -- Executing NoOp("SIP/3333-081d2c38", "CONTEXT2") in new stack > -- Executing NoOp("SIP/3333-081d2c38", "") in new stack > > If I flip their order in the agi, then ISLOCALDID gets set, but not > ISLOCALCONTEXT: > > -- Executing NoOp("SIP/3333-081d8d78", "") in new stack > -- Executing NoOp("SIP/3333-081d8d78", "4444") in new stack > > > Any idea what I am missing? Only the first "exec setvar" gets run and the > other one appears to just be ignored. I just want to be able to set 2-3 > variables and then return to the dialplan. Please note that I do not want > to use phpagi so don't tell me to use that, I want to figure out why it > doesn't work this way. >Are you reading the return value from asterisk in between them? j
On Thu, 4 Jun 2009, Peder wrote:> Is there a limitation to the number of variables you can set from a PHP > agi script?Not that I've found yet :) One of my AGIs sets almost 600 channel variables. It (written in C) takes all of 1/100 of a second to lookup the variables from 2 tables in a MySQL database and set all of the variables. [snip]> Here is the part from the agi that sets the variables: > > echo ' EXEC SetVar ISLOCALCONTEXT="'.$row['context'].'"'; > echo ' EXEC SetVar ISLOCALDID="'.$row['did'].'"';You are violating the AGI protocol. First, you have to read the AGI environment. Then, for every request, you must read the response. You will save yourself a lot of time and hair if you use an established library. Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Peder schrieb:> Here is the part from the agi that sets the variables: > > echo ' EXEC SetVar ISLOCALCONTEXT="'.$row['context'].'"'; > echo ' EXEC SetVar ISLOCALDID="'.$row['did'].'"'; > > If I run it is as, ISLOCALCONTEXT gets set, but not ISLOCALDID: > > -- Executing NoOp("SIP/3333-081d2c38", "CONTEXT2") in new stack > -- Executing NoOp("SIP/3333-081d2c38", "") in new stack > > If I flip their order in the agi, then ISLOCALDID gets set, but not > ISLOCALCONTEXT: > > -- Executing NoOp("SIP/3333-081d8d78", "") in new stack > -- Executing NoOp("SIP/3333-081d8d78", "4444") in new stack > > Any idea what I am missing? Only the first "exec setvar" gets run and the > other one appears to just be ignored. I just want to be able to set 2-3 > variables and then return to the dialplan. Please note that I do not want > to use phpagi so don't tell me to use that, I want to figure out why it > doesn't work this way.Send a newline ("\n") after each command. Remove the blank (" ") before the commands. And maybe use SET VARIABLE instead of EXEC SetVar. Philipp Kempgen -- AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied -> http://www.amooma.de Gesch?ftsf?hrer: Stefan Wintermeyer, Handelsregister: Neuwied B14998 Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de Videos of the AMOOCON VoIP conference 2009 -> http://www.amoocon.de --