execute particular command

@return
@throws IOException
332596
public static int execute(String[] commandArray, String[] alternativeEnvVars, File workingDir, Receiver outputReceiver) throws IOException {
		Runtime rt = Runtime.getRuntime();
		//command + arguments, environment parameters, workingdir
        Process proc = null;
        try {
		    proc = rt.exec(commandArray, alternativeEnvVars, workingDir);
        } catch (Exception e) {
            System.out.println("unable to execute command: " + ArraySupport.format(commandArray, ", "));
            e.printStackTrace();
            throw new RuntimeException("unable to execute command: " + ArraySupport.format(commandArray, ", "), e);
        }

		// any error message?
		Transponder errorForwarder = new
				Transponder(proc.getErrorStream(), new Pipe(outputReceiver));

		// any output?
		Transponder outputForwarder = new
				Transponder(proc.getInputStream(), new Pipe(outputReceiver));

		errorForwarder.start();
		outputForwarder.start();

		try {
			int retval = proc.waitFor();//threads will stop when proc is done and InputStream and ErrorStream close
			errorForwarder.stop();
			outputForwarder.stop();
			return retval;
		}
		catch (InterruptedException ie) {
			//...
		}
		return -1;
	}
199065
public int execute(final String user, final List<String> command) throws IOException {
    log.info("Command: " + command);
    final Process process = new ProcessBuilder()
        .command(constructExecuteAsCommand(user, command))
        .inheritIO()
        .start();

    int exitCode;
    try {
      exitCode = process.waitFor();
    } catch (final InterruptedException e) {
      log.error(e.getMessage(), e);
      exitCode = 1;
    }
    return exitCode;
  }
1244932
@Override
    protected void doExecute() throws Exception {
        final CommandHandler commandHandler = new CommandHandlerImpl(this.getLog());

        checkStageDirectoryExistence();

        checkRuntimeExistence(commandHandler);

        runFunctions(commandHandler);
    }
338287
public static void run(String[] command) throws IOException, RDF4JException, TrustyUriException {
		String cmd = command[0];
		String[] cmdArgs = Arrays.copyOfRange(command, 1, command.length);
		if (cmd.equals("CheckFile")) {
			CheckFile.main(cmdArgs);
		} else if (cmd.equals("ProcessFile")) {
			ProcessFile.main(cmdArgs);
		} else if (cmd.equals("CheckLargeRdf")) {
			CheckLargeRdf.main(cmdArgs);
		} else if (cmd.equals("TransformRdf")) {
			TransformRdf.main(cmdArgs);
		} else if (cmd.equals("TransformLargeRdf")) {
			TransformLargeRdf.main(cmdArgs);
		} else if (cmd.equals("CheckSortedRdf")) {
			CheckSortedRdf.main(cmdArgs);
		} else {
			System.err.println("ERROR: Unrecognized command " + cmd);
			System.exit(1);
		}
	}
847429
@Override
	public void run()
    {
        String command = globalSettings.getStringProperty(FFMQAdminClientSettings.ADM_COMMAND, null);
        if (StringTools.isEmpty(command))
        {
            err.println("No command specified");
            return;
        }
        
        try
        {
            openSession();
            processCommand(command);
        }
        catch (JMSException e)
        {
        	logError(e);
        }
        finally
        {
        	closeSession();
        }
    }
1179433
private void execute(String command) throws XAException {
    try {
      connection.createStatement().execute(command);
    } catch (SQLException sqle) {
      throw mapXaException(sqle);
    }
  }
610907
public String execGet(String command) throws IOException, PHPException {
		writeCommand("G" + command);
		phpConsoleLogger.write(command);
		String res = readLine();
		phpConsoleLogger.read(res);
		return res;
	}
416366
private Object execute(Object o, Method m, Object... args) throws CommandActionExecutionException {
        Object result = null;
        try {
            m.setAccessible(true); // suppress Java language access
            if (isCompileWeaving() && metaHolder.getAjcMethod() != null) {
                result = invokeAjcMethod(metaHolder.getAjcMethod(), o, metaHolder, args);
            } else {
                result = m.invoke(o, args);
            }
        } catch (IllegalAccessException e) {
            propagateCause(e);
        } catch (InvocationTargetException e) {
            propagateCause(e);
        }
        return result;
    }
1338644
public static void exec(ProcessBuilder pb) throws IOException
    {
        Process p = pb.start();
        try
        {
            int errCode = p.waitFor();
            if (errCode != 0)
            {
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
                StringBuilder sb = new StringBuilder();
                String str;
                while ((str = in.readLine()) != null)
                    sb.append(str).append(System.getProperty("line.separator"));
                while ((str = err.readLine()) != null)
                    sb.append(str).append(System.getProperty("line.separator"));
                throw new IOException("Exception while executing the command: "+ StringUtils.join(pb.command(), " ") +
                                      ", command error Code: " + errCode +
                                      ", command output: "+ sb.toString());
            }
        }
        catch (InterruptedException e)
        {
            throw new AssertionError(e);
        }
    }
1359430
@SuppressWarnings("unchecked")
    @Override
    public Boolean execute() {
        User sfsSender = CommandUtil.getSfsUser(sender, api);
        User sfsRecipient = CommandUtil.getSfsUser(recipient, api);
        if(sfsSender == null || sfsRecipient == null)
            return Boolean.FALSE;
        message = (message == null) ? "" : message;
        ISFSObject sfsParams = null;
        if(params != null) {
            MessageParamsClass clazz = context.getMessageParamsClass(params.getClass());
            if(clazz != null) 
                sfsParams = new ResponseParamSerializer().object2params(clazz.getUnwrapper(), params);
        }
        if(sfsParams == null) sfsParams = new SFSObject();
        try {
            api.sendBuddyMessage(sfsSender, sfsRecipient, message, sfsParams);
        } catch (SFSBuddyListException e) {
            throw new IllegalStateException(e);
        }
        return Boolean.TRUE;
    }
777388
public static void exec_command(String command) throws IOException {
        launchProcess(command, new HashMap<String, String>(), false);
    }
1151102
public static HttpResponse execute(HttpRequestBase request) throws IOException {

		Assert.notNull(request, "Missing request!");
		HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new DefaultRedirectStrategy()).build();
		return client.execute(request);
	}
995713
void handle() throws IOException {
        if (null == handler) {
            println("Command not recognized: %s", command());
            return;
        }
        if (handler == Exit.INSTANCE) {
            handler.handle(this);
        }
        CommandLineParser parser = commandLine();
        boolean help = parser.getBoolean("-h", "--help");
        if (help) {
            Help.INSTANCE.showHelp(parser.command(), this);
        } else {
            try {
                session.handler(handler);
                handler.handle(this);
            } catch ($.Break b) {
                throw b;
            } catch (Exception e) {
                console.println("Error: " + e.getMessage());
            }
        }
    }
73114
def executeCommand(self, command):
        
        if not command.strip():
            return self.waitForInput()
        
        # store the current block
        self._history.append(command)
        self._currentHistoryIndex = len(self._history)
        
        lines = []
        for line in command.split('\n'):
            line = re.sub('^>>> ', '', line)
            line = re.sub('^\.\.\. ', '', line)
            lines.append(line)
        
        command = '\n'.join(lines)
        
        # ensure we are at the end
        self.moveCursor(QTextCursor.End)
        self.scrollToEnd()
        self.insertPlainText('\n')
        cmdresult = None
        
        try:
            cmdresult = eval(command, self.scope(), self.scope())
        
        except SyntaxError:
            exec(command) in self.scope(), self.scope()
        
        else:
            if cmdresult is not None:
                # check to see if the command we executed actually caused
                # the destruction of this object -- if it did, then
                # the commands below will error
                if self.isDestroyed():
                    return
                
                try:
                    result = projex.text.nativestring(repr(cmdresult))
                except:
                    result = '<<< error formatting result to utf-8 >>>'
                
                self.information(result)
        
        finally:
            self.waitForInput()
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 "";
    }
650753
private String executeCommand() throws IOException, InterruptedException {
        ProcessBuilder processBuilder = new ProcessBuilder(command);

        ByteArrayOutputStream commandOutput = new ByteArrayOutputStream();

        Process process = processBuilder.start();
        try {
            IOUtils.copy(process.getInputStream(), commandOutput, processOutputLimit);

            process.waitFor();

            if (process.exitValue() != 0) {
                throw new IllegalStateException("Command returned non-zero exit value: " + process.exitValue());
            }

            return new String(commandOutput.toByteArray(), StringUtils.UTF8);
        } finally {
            process.destroy();
        }
    }
1142833
public static Execed appAs(String as, Iterable<String> command) throws IOException
	{
		Exec e = new Exec(command);
		if (as != null)
			e.runAs(as);
		e.setRedirectError(false);

		return e.start();
	}