You are here

function environment_indicator_execute_os_command in Environment Indicator 7.2

Execute a system command and return the results.

Parameters

string $command: The command to execute.

Return value

string The results of the string execution.

2 calls to environment_indicator_execute_os_command()
command_exists in ./environment_indicator.module
Determines if a command exists on the current environment.
environment_indicator_environment_indicator_matched_indicator_alter in ./environment_indicator.module
Implements hook_environment_indicator_matched_indicator_alter().

File

./environment_indicator.module, line 662
Module implementation file.

Code

function environment_indicator_execute_os_command($command) {
  $process = proc_open($command, array(
    // STDIN.
    0 => array(
      "pipe",
      "r",
    ),
    // STDOUT.
    1 => array(
      "pipe",
      "w",
    ),
    // STDERR.
    2 => array(
      "pipe",
      "w",
    ),
  ), $pipes);
  if ($process === FALSE) {
    return FALSE;
  }
  $stdout = stream_get_contents($pipes[1]);
  $stderr = stream_get_contents($pipes[2]);
  fclose($pipes[1]);
  fclose($pipes[2]);
  proc_close($process);
  return $stdout;
}