agave-systems/systems-core/src/main/java/org/iplantc/service/remote/local/CmdLineProcessHandler.java
/**
     * Executes the commandline string and collects the std_out and std_err of the child process.
     * @param commandLine the commands sent via command line to shell
     * @return the exitValue from the child process
     */
Executes the commandline string and collects the std_out and std_err of the child process.
@param commandLine the commands sent via command line to shell
@return the exitValue from the child process
Executes the commandline string and collects the std_out and std_err of the child process . @param commandLine the commands sent via command line to shell @return the exitValue from the child process
public int executeCommand(String commandLine){
        log.debug("Attempted command : "+commandLine);
        CommandLine command = new CommandLine("/bin/bash");
        command.addArgument("-l");
        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        try {
            is = new ByteArrayInputStream(commandLine.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        PumpStreamHandler streamHandler = new PumpStreamHandler(clog,elog,is);
        executor.setStreamHandler(streamHandler);
        try {
            executor.execute(command, resultHandler);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            resultHandler.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        exitValue = resultHandler.getExitValue();
        cpo = new CmdLineProcessOutput(exitValue,clog.getLinesAsString(),elog.getLinesAsString());
        return exitValue;
    }
public int executeCommand ( String commandLine ) { log . debug ( "Attempted command : " + commandLine ) ; CommandLine command = new CommandLine ( "/bin/bash" ) ; command . addArgument ( "-l" ) ; DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler ( ) ; try { is = new ByteArrayInputStream ( commandLine . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } PumpStreamHandler streamHandler = new PumpStreamHandler ( clog , elog , is ) ; executor . setStreamHandler ( streamHandler ) ; try { executor . execute ( command , resultHandler ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } try { resultHandler . waitFor ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } exitValue = resultHandler . getExitValue ( ) ; cpo = new CmdLineProcessOutput ( exitValue , clog . getLinesAsString ( ) , elog . getLinesAsString ( ) ) ; return exitValue ; }
Executes the commandline string and collects the std_out and std_err of the child process.
Executes the commandline string and collects the std_out and std_err of the child process .
// runs commands in a bash login shell //        executor.setWatchdog(watchdog); // execute command // wait for the process to complete