Hi, <br><br>thanks for the replies although i am still confused. <br><br>my agi script is <br><br>exten =&gt; _.,1,AGI(simple_c_prgm|999);<br>exten =&gt; _.,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 &lt;stdio.h&gt;<br>int main(int argc, char *argv[])<br>{<br><br>&nbsp; char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line[80];<br>&nbsp; int i;<br>&nbsp; /* use line buffering */<br><br>&nbsp; setlinebuf(stdout);<br>&nbsp; setlinebuf(stderr);<br><br>&nbsp; while (1) {
<br>&nbsp;&nbsp;&nbsp; /*gives me all the agi env var*/<br>&nbsp;&nbsp;&nbsp; fgets(line,80,stdin);<br>&nbsp; <br>&nbsp; //prints the variables<br>&nbsp;&nbsp;&nbsp; printf(&quot;--&gt; %s&quot;,line);<br>&nbsp;&nbsp;&nbsp; if (strlen(line) &lt;= 1) break;<br><br>&nbsp; }<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>&nbsp; for(i=0 ;i&lt;=argc ;i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;%s&quot;, argv[i]);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; /* Send asterisk a command */<br>&nbsp; printf(&quot;SET VARIABLE AGIVAR %s&quot;,argv[1] );
<br><br>&nbsp; /* Read response from Asterisk and show on console */<br>&nbsp; fgets(line,80,stdin);<br>&nbsp; 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 &lt;<a href="mailto:asterisk.org@sedwards.com">asterisk.org@sedwards.com</a>&gt; 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>&gt; I handle this (in Perl) using Getopt::Long, which knows nothing of AGI&#39;s<br>&gt; 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 &quot;agi debug&quot; at the Asterisk prompt. It&#39;s a fixed<br>list you get whether you want them or not. It&#39;s a common mistake for the<br>beginning AGI programmer to not read them (thus emptying stdin) and then
<br>wonder why their AGI&#39;s don&#39;t work correctly.<br><br>Arguments are passed to the AGI as elements of argv[] (for C, my native<br>&quot;tongue&quot;). Thus, &quot;Getopt:Long&quot; (for Perl) or &quot;getopt_long()&quot; (for C) work
<br>as expected. Using a comma to separate the arguments is an &quot;asteriskism.&quot;<br><br>Passing multiple arguments this way has worked for as long as I&#39;ve been<br>using Asterisk -- several years.<br><br>Thanks in advance,
<br>------------------------------------------------------------------------<br><font color="#888888">Steve Edwards &nbsp; &nbsp; &nbsp;<a href="mailto:sedwards@sedwards.com">sedwards@sedwards.com</a> &nbsp; &nbsp; &nbsp;Voice: +1-760-468-3867 PST<br>
Newline &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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> &nbsp; <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