/** * @param cl The command line {@link Commandline} * @param systemOut {@link StreamConsumer} * @param systemErr {@link StreamConsumer} * @return return code. * @throws CommandLineException in case of a problem. */ public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr ) throws CommandLineException { return executeCommandLine( cl, null, systemOut, systemErr, 0 ); }
public int execute(StreamConsumer outStreamConsumer, StreamConsumer errStreamConsumer) throws CommandLineException { log.debug("Executing command line: " + commandline); return CommandLineUtils.executeCommandLine(commandline, outStreamConsumer, errStreamConsumer); }
/** * @param cl The command line to execute * @param systemIn The input to read from, must be thread safe * @param systemOut A consumer that receives output, must be thread safe * @param systemErr A consumer that receives system error stream output, must be thread safe * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout. * @return A return value, see {@link Process#exitValue()} * @throws CommandLineException or CommandLineTimeOutException if time out occurs */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds ) throws CommandLineException { return executeCommandLine( cl, systemIn, systemOut, systemErr, timeoutInSeconds, null ); }
/** * @param cl The command line {@link Commandline} * @param systemOut {@link StreamConsumer} * @param systemErr {@link StreamConsumer} * @param timeoutInSeconds The timeout. * @return return code. * @throws CommandLineException in case of a problem. */ public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds ) throws CommandLineException { return executeCommandLine( cl, null, systemOut, systemErr, timeoutInSeconds ); }
/** * @param cl The command line {@link Commandline} * @param systemIn {@link StreamConsumer} * @param systemOut {@link StreamConsumer} * @param systemErr {@link StreamConsumer} * @return return code. * @throws CommandLineException in case of a problem. */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr ) throws CommandLineException { return executeCommandLine( cl, systemIn, systemOut, systemErr, 0 ); }
/** * @param cl The command line to execute * @param systemIn The input to read from, must be thread safe * @param systemOut A consumer that receives output, must be thread safe * @param systemErr A consumer that receives system error stream output, must be thread safe * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout. * @param runAfterProcessTermination Optional callback to run after the process terminated or the the timeout was * exceeded, but before waiting on the stream feeder and pumpers to finish. * @return A return value, see {@link Process#exitValue()} * @throws CommandLineException or CommandLineTimeOutException if time out occurs */ public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds, @Nullable Runnable runAfterProcessTermination ) throws CommandLineException { return executeCommandLine( cl, systemIn, systemOut, systemErr, timeoutInSeconds, runAfterProcessTermination, null ); }
public static void launchSubversion( String line, String basedir ) throws VerificationException { try { Commandline cli = new Commandline( line ); cli.setWorkingDirectory( basedir ); Writer logWriter = new FileWriter( new File( basedir, LOG_FILENAME ) ); StreamConsumer out = new WriterStreamConsumer( logWriter ); StreamConsumer err = new WriterStreamConsumer( logWriter ); System.out.println( "Command: " + CommandLineUtils.toString( cli.getCommandline() ) ); int ret = CommandLineUtils.executeCommandLine( cli, out, err ); logWriter.close(); if ( ret > 0 ) { System.err.println( "Exit code: " + ret ); throw new VerificationException(); } } catch ( CommandLineException e ) { throw new VerificationException( e ); } catch ( IOException e ) { throw new VerificationException( e ); } }
return CommandLineUtils.executeCommandLine( cmd, out, err );
/** * @param cli {@link Commandline} * @param request The request. * @return {@link JavaToolRequest} */ protected JavaToolResult executeCommandLine( Commandline cli, Request request ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing: " + cli ); } JavaToolResult result = createResult(); result.setCommandline( cli ); InputStream systemIn = createSystemInputStream(); StreamConsumer systemOut = createSystemOutStreamConsumer( request ); StreamConsumer systemErr = createSystemErrorStreamConsumer( request ); try { int resultCode = CommandLineUtils.executeCommandLine( cli, systemIn, systemOut, systemErr ); result.setExitCode( resultCode ); } catch ( CommandLineException e ) { result.setExecutionException( e ); } return result; }