System call doesn't work

I can’t get Asterisk to properly execute a PHP with the System dial plan function:

exten => 121,1,System('/xml/pushStatusForward.php 667') exten => 121,n,NoOp(Result = ${SYSTEMSTATUS})
results in:

-- Executing System("SIP/7335-0861aa40", "/xml/pushStatusForward.php 667") in new stack -- Executing NoOp("SIP/7335-0861aa40", "Result = SUCCESS") in new stack
However, the PHP script is never executed. The PHP script writes to a log file and that log file never is written when the script is called via Asterisk.

On the Linux command line, [root@hgbn-asterisk xml]# /xml/pushStatusForward.php 667 works fine. I have even done [root@hgbn-asterisk xml]# su asterisk [asterisk@hgbn-asterisk xml]$ /bin/sh -c '/var/www/html/xml/pushStatusForward.php 667' which also works fine.

The only time this script doesn’t work is when called from System in the dial plan. PHP logs errors and no errors appear, it’s like the script isn’t even executed despite Asterisk’s claim of SUCCESS.

Any ideas?

Is Asterisk running as root or as a user that has the rights to execute that script? Why do a System call anyway? You could do an AGI which gives you a bit more control and validation. Easy enough with

Asterisk is running as user asterisk. If there were a rights issue then Asterisk should not report a status of SUCCESS. I su’d into the Asterisk user to test the script with success. It’s baffling.

I did not plan on using AGI because the script does not need to interact with Asterisk at all, just kick off an XML push to a SIP phone. But this may be the route I need to take.

Using AGI did work. I wonder why System can’t work with shell scripts…

It should be able to. Although I have only used the System call to do basic things, anytime I do something a little more sophisticated I go the AGI route.

System() works well with bash scripts