You'll need to use an array to get output.
So, use the following code:
$result=; // Create an array
exec('your command line', &$result); // Remember the & before the result as it ***IS A REFERENCE***
//DO whatever with your result
The problem is that you didn't pass your result array as a reference.
shell_exec, where your return value is everything returned:
You can also use backticks:
Create a new pointer with:
$handle = popen("/bin/ls", "r");
and then read it:
$read = fread($handle);
and close with:
It will block execution until the output stops.