I've read through a lot of similar SO questions about my issue, none seem to have my issue. If it's relevant, I'm running PHP 5.3.8 on Apache 2.2 and PHP exec() runs as nt authority\system
$cmd = "java -version";
$res = exec($cmd, $output, $return);
var_dump($res, $output, $return);
Produces:
string '' (length=0)
array
empty
int 0
$return being 0 hints that this was successful. Interestingly, if I run:
$cmd = "java -version 2> response";
A file is created with the expected output:
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
So my question: Why is $output not getting populated?
Comment update
Result of $res = exec("dir c:", $output, $return);
string ' 2 Dir(s) 335,636,791,296 bytes free' (length=51)
array
0 => string ' Volume in drive C is Local Disk' (length=32)
1 => string ' Volume Serial Number is D87C-E25C' (length=34)
2 => string '' (length=0)
...
12 => string ' 5 File(s) 1,158 bytes' (length=45)
13 => string ' 2 Dir(s) 335,636,791,296 bytes free' (length=51)
int 0