[asterisk-users] How to pass variable back and forth from dialplan to php file?

Steve Edwards asterisk.org at sedwards.com
Mon Jun 14 20:53:50 CDT 2010


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       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000


More information about the asterisk-users mailing list