Q1: You will have to parse the output of the command you run to see if it processed correctly. To do this see Q2.
Q2: See below:
PHP Code:
exec("[cmd]",$cmdresult);
foreach ($cmdresult AS $cmdresultline) {
$result .= "$cmdresultline\n";
}
echo $result;