Adding shell_get and migrating to Exception
This commit is contained in:
parent
44d935a1bf
commit
e34f22a06b
|
@ -377,7 +377,7 @@ function shell($cmd, &$out=null)
|
|||
{
|
||||
shell_try($cmd, $ret, $out);
|
||||
if($ret != 0)
|
||||
throw new TaskmanException("Shell execution error(exit code $ret)");
|
||||
throw new Exception("Shell execution error(exit code $ret)");
|
||||
}
|
||||
|
||||
function shell_try($cmd, &$ret=null, &$out=null)
|
||||
|
@ -391,6 +391,14 @@ function shell_try($cmd, &$ret=null, &$out=null)
|
|||
_execute_proc_cmd($cmd, $ret, $out);
|
||||
}
|
||||
|
||||
function shell_get($cmd, $as_string = true)
|
||||
{
|
||||
exec($cmd, $out, $code);
|
||||
if($code !== 0)
|
||||
throw new Exception("Error($code) executing shell cmd '$cmd'");
|
||||
return $as_string ? implode("", $out) : $out;
|
||||
}
|
||||
|
||||
function _execute_proc_cmd($cmd, &$ret, &$out)
|
||||
{
|
||||
//TODO: do we really need to redirect error stream?
|
||||
|
|
Loading…
Reference in New Issue