18 September, 2008

PHP - exec output

This is the simple way how to capture exec output:
<?php

function execOutput($command) {
$output = array($command);
exec($command.' 2>&1', $output);
return implode("\n", $output);
}

echo execOutput('help');
?>

No comments: