I have a PHP script that calls a command-line utility via exec. It works fine on my (Xubuntu linux based) development machine, but not in my (CentOS linux based) testing environment on the production server.
In order to isolate the error, I have created the following test script:
<?php
$command = "echo test";
$output = array();
exec($command, $output);
foreach ($output as $line)
{
echo "new line: " . $line . "\n";
}
echo "done";
?>
When I run this via php test.php, I get the following output.
done
I.e. it seems that the exec command does not produce any output, as is the case in my real script.
What is the cause of this behavior or where to look for further information?