Hi, <br><br>thanks for the replies although i am still confused. <br><br>my agi script is <br><br>exten => _.,1,AGI(simple_c_prgm|999);<br>exten => _.,2,NoOp(${MYAGIVAR});<br><br>Now i want to set the value of MYAGIVAR to 999 in my c program called simple_c_prgm. This is what I am doing:
<br><br>#include <stdio.h><br>int main(int argc, char *argv[])<br>{<br><br> char line[80];<br> int i;<br> /* use line buffering */<br><br> setlinebuf(stdout);<br> setlinebuf(stderr);<br><br> while (1) {
<br> /*gives me all the agi env var*/<br> fgets(line,80,stdin);<br> <br> //prints the variables<br> printf("--> %s",line);<br> if (strlen(line) <= 1) break;<br><br> }<br><br><br><b>//according to me the passed variable should be available here but i am not getting anything here
<br>//nothing gets printed on the agi debug command<br><br></b> for(i=0 ;i<=argc ;i++)<br> {<br> printf("%s", argv[i]);<br> }<br><br> /* Send asterisk a command */<br> printf("SET VARIABLE AGIVAR %s",argv[1] );
<br><br> /* Read response from Asterisk and show on console */<br> fgets(line,80,stdin);<br> fputs(line,stderr);<br><br><br>}<br><br><br>It would be great if someone could tell me what the problem is<br><br>Thanks<br><br>
Arpit<br><br><br><div class="gmail_quote">On Nov 2, 2007 5:24 PM, Steve Edwards <<a href="mailto:asterisk.org@sedwards.com">asterisk.org@sedwards.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Fri, 2 Nov 2007, James FitzGibbon wrote:<br><br>> I handle this (in Perl) using Getopt::Long, which knows nothing of AGI's<br>> stdin/stdout mechanics:<br><br></div>The AGI variables are passed via stdin (similar to an HTTP GET request)
<br>and can be observed using "agi debug" at the Asterisk prompt. It's a fixed<br>list you get whether you want them or not. It's a common mistake for the<br>beginning AGI programmer to not read them (thus emptying stdin) and then
<br>wonder why their AGI's don't work correctly.<br><br>Arguments are passed to the AGI as elements of argv[] (for C, my native<br>"tongue"). Thus, "Getopt:Long" (for Perl) or "getopt_long()" (for C) work
<br>as expected. Using a comma to separate the arguments is an "asteriskism."<br><br>Passing multiple arguments this way has worked for as long as I've been<br>using Asterisk -- several years.<br><br>Thanks in advance,
<br>------------------------------------------------------------------------<br><font color="#888888">Steve Edwards <a href="mailto:sedwards@sedwards.com">sedwards@sedwards.com</a> Voice: +1-760-468-3867 PST<br>
Newline Fax: +1-760-731-3000<br></font><div><div></div><div class="Wj3C7c"><br>_______________________________________________<br>--Bandwidth and Colocation Provided by <a href="http://www.api-digital.com--" target="_blank">
http://www.api-digital.com--</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users
</a><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>Arpit Mehta<br>Graduate Student<br>Department of Computer Science<br>Columbia University<br><br>Tel: 1-646-387-5998