leirbag leirbag - 1 year ago 135
PHP Question

Execute Asterisk client command with PHP

I'm trying to execute an Asterisk client command with PHP, to display with html. I used to do it normally. When the server was rebooted, I used to give 777 permissions to the file "/var/run/asterisk/asterisk.ctl" and then I could run a command and display it with PHP and HTML.

Now, I do all those steps, but when I try to display a command, nothing is shown, and Asterisk does not return any message. The command that I try to execute with PHP is:

exec('sudo asterisk -rx "sip show peers"',$data);

The variable $data returns nothing.

Answer Source

I think first you have check is "what is path for your apache account".

It is really unlikly apache see /usr/sbin/. So you need use full path to asterisk

Second thing you have check - if your sudo(/etc/sudoers) REALLY allow run asterisk for apache(or nobody, depend of your setup) user.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download