On Mon, 14 Jun 2010, bruce bruce wrote:

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:

asterisk -rx "sip show peer $sip_peer" | grep -c "X-Lite"'

Above ^^^ in Linux prompt returns 1 if $sip_peer is registered with X-Lite else it returns 0.

But using system() I think the "" confuse php and value is always returned as 0. $peer_count = system('asterisk -rx "sip show peer $sip_peer" | grep -c "X-Lite"', $retval);

Should $sip_peer be inside another set of parenthesis?

The single quotes are skipping the evaluation of $sip_peer.

Try something like this:

system('asterisk -rx "sip show peer ' . $sip_peer . '" | grep -c "X-Lite"')

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       [email protected]      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000
-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

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

Reply via email to