diff --git a/helpers.inc.php b/helpers.inc.php index 131dddc..f9394de 100644 --- a/helpers.inc.php +++ b/helpers.inc.php @@ -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?