List of usage examples for org.apache.commons.exec CommandLine CommandLine
public CommandLine(final CommandLine other)
From source file:io.selendroid.support.BaseAndroidTest.java
@BeforeClass public static void startSelendroidServer() throws Exception { CommandLine startSelendroid = new CommandLine(AndroidSdk.adb()); startSelendroid.addArgument("shell"); startSelendroid.addArgument("am"); startSelendroid.addArgument("instrument"); startSelendroid.addArgument("-e"); startSelendroid.addArgument("main_activity"); startSelendroid.addArgument("io.selendroid.testapp.HomeScreenActivity"); startSelendroid.addArgument("io.selendroid/.ServerInstrumentation"); ShellCommand.exec(startSelendroid);//w ww . ja v a2 s . co m CommandLine forwardPort = new CommandLine(AndroidSdk.adb()); forwardPort.addArgument("forward"); forwardPort.addArgument("tcp:8080"); forwardPort.addArgument("tcp:8080"); ShellCommand.exec(forwardPort); // instrumentation needs a beat to come up before connecting right away // without this the first test often will fail, there's a similar wait // in the selendroid-standalone HttpClientUtil.waitForServer(8080); }
From source file:com.adaptris.hpcc.DfuPlusConnectionTest.java
@Test public void testSourceIp() throws Exception { DfuplusConnection conn = new DfuplusConnection(); conn.setDfuplusCommand("/bin/dfuplus"); conn.setSourceIp("1.2.3.4"); conn.setServer("2.3.4.5"); CommandLine cmdLine = new CommandLine("/bin/dfuplus"); CommandLine cmd = conn.addArguments(cmdLine); assertEquals("server=2.3.4.5", cmd.getArguments()[0]); assertEquals("srcip=1.2.3.4", cmd.getArguments()[1]); }
From source file:net.robyf.dbpatcher.util.MySqlUtil.java
/** * Creates a new MySQL database./*from w w w . j a v a2s .c o m*/ * * @param databaseName The name for the new database * @param username Username of the MySQL administration user * @param password Password of the MySQL administration user */ public static void createDatabase(final String databaseName, final String username, final String password) { CommandLine command = new CommandLine("mysqladmin"); addCredentials(command, username, password); command.addArgument("create"); command.addArgument(databaseName); execute(command); }
From source file:name.martingeisse.webide.process.NodejsCompanionProcess.java
@Override protected CommandLine buildCommandLine() { CommandLine commandLine = new CommandLine(Configuration.getBashPath()); commandLine.addArgument("--login"); commandLine.addArgument("-c"); commandLine.addArgument("node " + mainFile.getName() + " " + getCompanionId(), false); return commandLine; }
From source file:com.github.nbyl.xfdcontrol.plugins.notification.blink1.Blink1ToolCommand.java
public Blink1ToolCommand(String blink1ToolPath) { this.commandLine = new CommandLine(blink1ToolPath); }
From source file:co.leantechniques.maven.scm.Cmd.java
public Cmd(String cmd) { this.cmd = new CommandLine(cmd); executor.setWatchdog(watchdog); }
From source file:eu.creatingfuture.propeller.blocklyprop.propeller.PropellerLoad.java
protected List<String> getPorts(String executable) { List<String> ports = new ArrayList<>(); try {//from w w w .j ava 2 s . com CommandLine cmdLine = new CommandLine(executable); cmdLine.addArgument("-P"); DefaultExecutor executor = new DefaultExecutor(); //executor.setExitValues(new int[]{451, 301}); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); executor.setStreamHandler(streamHandler); try { exitValue = executor.execute(cmdLine); } catch (ExecuteException ee) { exitValue = ee.getExitValue(); logger.log(Level.SEVERE, "Unexpected exit value: {0}", exitValue); return ports; } finally { output = outputStream.toString(); } /* if (exitValue == 301) { return ports; } */ // System.out.println("output: " + output); Scanner scanner = new Scanner(output); while (scanner.hasNextLine()) { ports.add(scanner.nextLine()); } return ports; } catch (IOException ioe) { logger.log(Level.SEVERE, null, ioe); return null; } }
From source file:eu.creatingfuture.propeller.webLoader.propeller.PropellerLoad.java
protected List<String> getPorts(String executable) { List<String> ports = new ArrayList<String>(); try {/*w w w. ja v a 2 s .c om*/ CommandLine cmdLine = new CommandLine(executable); cmdLine.addArgument("-P"); DefaultExecutor executor = new DefaultExecutor(); //executor.setExitValues(new int[]{451, 301}); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); executor.setStreamHandler(streamHandler); try { exitValue = executor.execute(cmdLine); } catch (ExecuteException ee) { exitValue = ee.getExitValue(); logger.log(Level.SEVERE, "Unexpected exit value: {0}", exitValue); return ports; } finally { output = outputStream.toString(); } /* if (exitValue == 301) { return ports; } */ // System.out.println("output: " + output); Scanner scanner = new Scanner(output); while (scanner.hasNextLine()) { ports.add(scanner.nextLine()); } return ports; } catch (IOException ioe) { logger.log(Level.SEVERE, null, ioe); return null; } }
From source file:de.torstenwalter.maven.plugins.ExpdpMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { CommandLine commandLine = new CommandLine(expdp); addCommonArguments(commandLine);/*from w w w . j ava 2 s .c o m*/ getLog().debug("Executing command line: " + obfuscateCredentials(commandLine.toString(), getCredentials())); Executor exec = new DefaultExecutor(); exec.setStreamHandler(new PumpStreamHandler(System.out, System.err)); try { exec.execute(commandLine); } catch (ExecuteException e) { throw new MojoExecutionException("Command execution failed.", e); } catch (IOException e) { throw new MojoExecutionException("Command execution failed.", e); } }
From source file:com.jaeksoft.searchlib.util.ExecuteUtils.java
final public static int command(File workingDirectory, String cmd, String classpath, boolean setJavaTempDir, OutputStream outputStream, OutputStream errorStream, Long timeOut, String... arguments) throws ExecuteException, IOException { Map<String, String> envMap = null; if (classpath != null) { envMap = new HashMap<String, String>(); envMap.put("CLASSPATH", classpath); }/* ww w .j av a2 s. co m*/ CommandLine commandLine = new CommandLine(cmd); if (setJavaTempDir) if (!StringUtils.isEmpty(SystemUtils.JAVA_IO_TMPDIR)) commandLine.addArgument(StringUtils.fastConcat("-Djava.io.tmpdir=", SystemUtils.JAVA_IO_TMPDIR), false); if (arguments != null) for (String argument : arguments) commandLine.addArgument(argument); DefaultExecutor executor = new DefaultExecutor(); if (workingDirectory != null) executor.setWorkingDirectory(workingDirectory); if (outputStream != null) { PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(outputStream, errorStream); executor.setStreamHandler(pumpStreamHandler); } if (timeOut != null) { ExecuteWatchdog watchdog = new ExecuteWatchdog(timeOut); executor.setWatchdog(watchdog); } return envMap != null ? executor.execute(commandLine, envMap) : executor.execute(commandLine); }