I do have a rather bigger project coming my way and I would really like to know how to do the <b><i>&quot;feeding a text file into the STDIN of your AGI so you can debug completely external to Asterisk&quot;</i></b><div><b><i><br>

</i></b></div><div><b><i><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-style: normal;">However, for this project, it seems that I can use php system() along with grep to see the status of a peer with one line of code:</span></span></i></b></div>

<div><b><i><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-style: normal;"><br></span></span></i></b></div><div><b><i><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-style: normal;"><div>

<b><i><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-style: normal;"><div style="display: inline !important; "><b><i><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-style: normal; "><div style="display: inline !important; ">

<b>asterisk -rx &quot;sip show peer $sip_peer&quot; | grep -c &quot;X-Lite&quot;&#39;</b></div></span></span></i></b></div></span></span></i></b></div><div>Above ^^^ in Linux prompt returns 1 if $sip_peer is registered with X-Lite else it returns 0.</div>

<div><br></div><div>But using system() I think the &quot;&quot; confuse php and value is always returned as 0.</div><div><b><i><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-style: normal; "><div>

<b>$peer_count = system(&#39;asterisk -rx &quot;sip show peer $sip_peer&quot; | grep -c &quot;X-Lite&quot;&#39;, $retval);</b></div></span></span></i></b></div><div><br></div><div>Should $sip_peer be inside another set of parenthesis?</div>

<div><br></div><div>Thanks,</div><div>Bruce</div><div><br></div></span></span></i></b><div class="gmail_quote">On Mon, Jun 14, 2010 at 6:44 PM, Steve Edwards <span dir="ltr">&lt;<a href="http://asterisk.org">asterisk.org</a>@<a href="http://sedwards.com">sedwards.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Mon, 14 Jun 2010, bruce bruce wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for the input. I actually did use verbose() and that is when I noticed that my path to phpagi was not right since nothing was coming through. For return value prior to fixing phpagi path, I was getting:<br>
<br>
NoOp(&quot;SIP/64.111.222.111-00000ca7&quot;, &quot;&quot;)<br>
<br>
which actually is just right because if you notice the last three charecters of that line is &quot;&quot;). So, when the phpagi path is correct, it looks like:  &quot;415444555&quot;).<br>
</blockquote>
<br></div>
Which is why enabling AGI debugging and posting actual console code can speed problem resolution. Sometimes it&#39;s just another set of eyes on the same output :)<br>
<br>
If you&#39;re going to be developing a significant bit of AGI code, there is a &quot;not immediately obvious&quot; technique of feeding a text file into the STDIN of your AGI so you can debug completely external to Asterisk -- even within an IDE like emacs+gdb. (Or whatever the PHP equivalence is.)<br>

<font color="#888888">
<br>
-- <br></font><div><div></div><div class="h5">
Thanks in advance,<br>
-------------------------------------------------------------------------<br>
Steve Edwards       <a href="mailto:sedwards@sedwards.com" target="_blank">sedwards@sedwards.com</a>      Voice: +1-760-468-3867 PST<br>
Newline                                              Fax: +1-760-731-3000</div></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</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></blockquote></div><br></div>