Execute a PowerShell command.
<p>
This method launch a thread which will be executed in the already created
PowerShell console context

@param command the command to call. Ex: dir
@return PowerShellResponse the information returned by powerShell
334591
public PowerShellResponse executeCommand(String command) {
        String commandOutput = "";
        boolean isError = false;
        boolean timeout = false;

        checkState();

        PowerShellCommandProcessor commandProcessor = new PowerShellCommandProcessor("standard", p.getInputStream(),
                this.waitPause, this.scriptMode);
        Future<String> result = threadpool.submit(commandProcessor);

        // Launch command
        commandWriter.println(command);

        try {
            if (!result.isDone()) {
                try {
                    commandOutput = result.get(maxWait, TimeUnit.MILLISECONDS);
                } catch (TimeoutException timeoutEx) {
                    timeout = true;
                    isError = true;
                    //Interrupt command after timeout
                    result.cancel(true);
                }
            }
        } catch (InterruptedException | ExecutionException ex) {
            logger.log(Level.SEVERE,
                    "Unexpected error when processing PowerShell command", ex);
            isError = true;
        } finally {
            // issue #2. Close and cancel processors/threads - Thanks to r4lly
            // for helping me here
            commandProcessor.close();
        }

        return new PowerShellResponse(isError, commandOutput, timeout);
    }
191434
public void execute(Runnable command) {
        if (!(command instanceof ClusteredFutureTask)) {
            command = new ClusteredFutureTask<Object>(command, null);
        }
        command.run();
    }
600596
public Process execute()
    throws IOException
    {
        List<String>  list = createCommandList();
        if (_LOG_.isDebugEnabled()) {
            _LOG_.debug( "executing command: " + list );
        }

        Process  proc = Runtime.getRuntime().exec( list.toArray( new String[0] ) );
                                             //@throws IOException
                                             //@throws SecurityException
                                             //@throws IndexOutOfBoundsException, NullPointerException

        return proc;
    }
606944
public static function execute( $command, $directory = null, $timeout = 120 ) {
		$directory = $directory !== null ? $directory : getcwd();

		$process = new Process( $command, null, null, null, $timeout );
		$process->setWorkingDirectory( $directory );
		$process->mustRun();

		return $process->getOutput();
	}
622412
public <R> R executeAndQuery(ContextCommand<ROOT, R> cmd) {
        return Politician.beatAroundTheBush(() -> this.prevayler.execute(new InternalTransaction<>(cmd)));
    }
1113628
public function execute($command = null, array $args = array(), array $options = array())
    {
        $command = $command ?: $this->defaultCommand;
        if (!isset($this->commands[$command])) {
            throw new ConsoleException("Command '$command' does not exist");
        }
        
        $callback = $this->commands[$command];
        if (is_callable($callback)) {
            $params = array($args, $options);
            if (is_string($callback)) {
                if (strpos($callback, '::') !== false) {
                    list($classname, $methodname) = explode('::', $callback);
                    $reflection = new ReflectionMethod($classname, $methodname);
                } else {
                    $reflection = new ReflectionFunction($callback);
                }
                $params = Utils::computeFuncParams($reflection, $args, $options);
            }
            $params[] = $this;
            return call_user_func_array($callback, $params);
        }

        $method = new ReflectionMethod($callback, 'execute');
        $params = Utils::computeFuncParams($method, $args, $options);
        return $method->invokeArgs(new $callback($this), $params);
    }
1370207
@Override
    public void execute(Runnable command)
    {
        super.execute(isTracing() && !(command instanceof TraceSessionWrapper)
                      ? new TraceSessionWrapper<Object>(Executors.callable(command, null))
                      : command);
    }
773886
final public function execute($command, AnCommandContext $context)
    {
        $identifier = $context->caller->getIdentifier();

        if ($context->entity instanceof AnDomainEntityAbstract) {
            $identifier = $context->entity->getIdentifier();
        }

        $type = $identifier->path;
        $type = array_pop($type);

        $parts = explode('.', $command);
        $method = '_'.($parts[0]).ucfirst($type).ucfirst($parts[1]);

        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        if ($context->entity) {
            $result = $context->entity->execute($command, $context);
        }

        return $result;
    }
28311
protected Pair<Integer, InputStream> executeCommand(String command) {
        int resultVal = 1;
        InputStream inputStream = null;
        try {
            logger.debug("Executing command: {}", command);
            Process process =  Runtime.getRuntime().exec(command);

            resultVal = process.waitFor();
            inputStream = process.getInputStream();

        } catch (InterruptedException e) {
            logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
            Thread.currentThread().interrupt();
        } catch (IOException  e) {
            logger.info("Execution of {} failed: code - {} ; message - {}", command, resultVal, e.getMessage());
        }
        if (inputStream == null) {
           // Create an empty InputStream instead of returning a null
           inputStream = new InputStream() {
               @Override
               public int read() throws IOException {
                   return -1;
               }
           } ;
        }
        return new Pair<>(resultVal, inputStream);
    }
1325319
public static String runShellCommand( Session session, String command ) throws JSchException, IOException {
        String remoteResponseStr = launchACommand(session, command);
        return remoteResponseStr;
    }
359250
private String executeCommand(String command) {
        System.out.println("Execute: " + command);

        StringBuilder output = new StringBuilder();
        Process       p;
        try {
            p = Runtime.getRuntime().exec(command);
            p.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String         line;
            while ((line = reader.readLine()) != null) {
                output.append(line).append("\n");
            }
        } catch (Exception e) {
            throw new WebpIOException(e);
        }
        if (!"".equals(output.toString())) {
            System.out.println("Output: " + output);
        }
        return "";
    }
1090421
public RESTResponse runCommand(Command command)  {
        if (this.applicationName != null) {
            command.setApplicationName(this.applicationName);
        }
        if (this.storageService != null) {
            command.setStorageService(this.storageService);
        }       
        if (this.restMetadataJson != null) {
            command.setRestMetadataJson(this.restMetadataJson);
        }
        command.validate(restClient);
        return command.call(restClient);        
    }
844594
public static int execute(String command, String[] envVars, File dir, Receiver outputReceiver) throws IOException {
		return execute(getCommandArrayForCurrentOS(command), envVars, dir, outputReceiver);
	}
824783
private void voidCommand(final String command) throws IOException {
		synchronized (this.asyncMutex) {
			this.out.write(command + "\n");
			this.out.flush();
		}
	}
1314291
public function execute($command)
    {
        $deferred = new Deferred();

        if ($this->ending) {
            $deferred->reject(new RuntimeException('Shell is ending already'));
        } else {
            $this->pending []= $deferred;

            $this->sendCommand($command);
        }

        return $deferred->promise();
    }
363173
protected function executeCommand($command) {
        $class = $this->config['commands'][$command]['class'];

        if (!class_exists($class) ||
            !is_subclass_of($class, __NAMESPACE__ . '\\Command\\Executes')
        ) {
            throw new RuntimeException(sprintf(
                'Command "%s" not found',
                $command
            ), ExitApp::BAD_USER_INTERACTION);
        }

        $this->config['command'] = $command;

        /** @var Executes $command */
        $command = new $class($this->config, $this->log);

        foreach ($this->config['args'] as $help) {
            if (in_array($help, ['-h', '--help'])) {
                $command->printUsage();
                return;
            }
        }

        $command->setup()->execute()->tearDown();
    }
843719
@Override
    public JSObject execute(String command) {
        Object returnValue = engine.executeScript(command);
        if (returnValue instanceof JSObject) {
            return (JSObject) returnValue;
        }

        return null;
    }