Commit 1732bf68 authored by Clément Démoulins's avatar Clément Démoulins
Browse files

Provide a new function to help running binaries.

parent 413716b6
......@@ -6,6 +6,8 @@ include_once "inc/page.php";
abstract class DemoPage extends Page
{
protected $last_output;
// Default functions.
public function __construct()
......@@ -167,4 +169,24 @@ SCRIPT;
return "";
}
// exec_args[0] MUST be the binary name.
protected function run($bin, $args, $save_output = true)
{
global $ld_library_path;
// Build command line.
$cmd = "sudo -u webapp LD_LIBRARY_PATH=$ld_library_path $bin $args";
// System call to run the program.
$output = "";
exec($cmd, $output, $retval);
handle_errors($retval, $output);
if ($save_output)
$this->last_output = $output;
return $retval;
}
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment