PHP exec - missing output
I am currently trying to get SoX working through PHP. It all works so far, but I don't get the output back. I've already read that one might route stderr also to the output with "2>&1" .. the problem is, this doesn't seem to work on windows machines.
any other ideas?
code is as follows:
exec($path2sox . '/sox ' . $cmd . ' 2>&1', $output = array(), $result);
whereas the file gets created (so basic sox command 开发者_运维技巧is okay, i also tested it exactly the same command in the windows commandline), but neither result nor output give something in return (SoX verbosity is set to 4, which is full output)
I suppose, windows doesnt understand the 2>&1 statement, but how can this be overcome?
P.S: as suggested below, I also tried this
$output = array();
echo "Executing: [$path2sox/sox $cmd]";
exec("$path2sox/sox $cmd", $output, $result);
echo "Result: ";
var_dump($result);
echo "\nOutput: ";
var_dump($output);
where the output is:
Executing: [I:\SoX/sox --guard -V4 "somedirectory/test.wav" --compression "320.2" "somedirectory/test.mp3"]Result: int(0) Output: array(0) { }File was created properly ...
Are you passing the second output array parameter?
http://us2.php.net/manual/en/function.exec.php
string exec ( string $command [, array &$output [, int &$return_var ]] )
output
If the output argument is present, then the specified array will be filled with every line of output from the command. Trailing whitespace, such as \n, is not included in this array. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec().
I suspect you might be right that windows isn't liking the 2>&1
statement. What do you see when you try:
$output = array()
echo "Executing: [$path2sox/sox $cmd]";
exec("$path2sox/sox $cmd", $output, $result);
echo "Result: ";
var_dump($result);
echo "\n<br>Output: ";
var_dump(output);
精彩评论