String line = "myCommand.exe"; CommandLine commandLine = CommandLine.parse(line); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(1); int exitValue = executor.execute(commandLine);
private static DefaultExecutor getDefaultExecutor(File dir, int expectedExit, long timeout) { DefaultExecutor executor = new DefaultExecutor(); if(expectedExit != -1) { executor.setExitValue(expectedExit); } else { executor.setExitValues(null); } ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout); executor.setWatchdog(watchdog); executor.setWorkingDirectory(dir); return executor; }
executor.setExitValue(0); if (StringUtils.isBlank(workDir) == false) { executor.setWorkingDirectory(new File(workDir));
executor.setExitValue(0); if (!StringUtils.isBlank(workDir)) { executor.setWorkingDirectory(new File(workDir));
public static int executeCommand(CommandLine command, Logger log) throws ExecuteException, IOException { DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); PumpStreamHandler psh = new PumpStreamHandler(new ExecLogHangler(log, Level.DEBUG), new ExecLogHangler(log, Level.ERROR)); executor.setStreamHandler(psh); return executor.execute(command); }
private String computePoT(File input) throws IOException, TikaException { CommandLine cmdLine = new CommandLine("pooled-time-series"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); cmdLine.addArgument("-f"); cmdLine.addArgument(input.getAbsolutePath()); LOG.trace("Executing: {}", cmdLine); DefaultExecutor exec = new DefaultExecutor(); exec.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); exec.setWatchdog(watchdog); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); exec.setStreamHandler(streamHandler); int exitValue = exec .execute(cmdLine, EnvironmentUtils.getProcEnvironment()); return outputStream.toString("UTF-8"); }
public void setExitValue(int exitValue) { executor.setExitValue(exitValue); }
String toolkitCmd= "cmd_to_start_toolkit"; CommandLine commandLine = CommandLine.parse(toolkitCmd); DefaultExecutor myexecutor = new DefaultExecutor(); myexecutor.setExitValue(1); int exeValue= myexecutor.execute(commandLine);
public int run(final String args) { final CommandLine cmdLine = CommandLine.parse(args); final DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(CORRECT_EXECUTION_VALUE); try { return executor.execute(cmdLine); } catch (ExecuteException e) { LOGGER.error("Execute exception", e); } catch (IOException e) { LOGGER.error("IOException exception", e); } return -1; } }
CommandLine cmdLine = CommandLine.parse(command); for (String comm : cmd) { cmdLine.addArgument(comm); } DefaultExecutor exec = new DefaultExecutor(); exec.setExitValue(0); exec.setWorkingDirectory(new File(codeDir)); exitCode = exec.execute(cmdLine);
private int execute(CommandLine commandLine, int timeout) throws IOException { DefaultExecutor executor = new DefaultExecutor(); ExecuteWatchdog watchdog = new ExecuteWatchdog(TimeUnit.SECONDS.toMillis(timeout)); executor.setWatchdog(watchdog); executor.setExitValue(0); return executor.execute(commandLine); }
Map map = new HashMap(); map.put("file", new File("invoice.pdf")); CommandLine cmdLine = new CommandLine("AcroRd32.exe"); cmdLine.addArgument("/p"); cmdLine.addArgument("/h"); cmdLine.addArgument("${file}"); cmdLine.setSubstitutionMap(map); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(1); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); executor.setWatchdog(watchdog); int exitValue = executor.execute(cmdLine);
public boolean run(String args) { String cli = executable.getAbsolutePath() + " " + args; System.out.println(">> " + cli); CommandLine parse = CommandLine.parse(cli); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); try { return executor.execute(parse) == 0; } catch (IOException e) { e.printStackTrace(); return false; } }
private String computePoT(File input) throws IOException, TikaException { CommandLine cmdLine = new CommandLine("pooled-time-series"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); cmdLine.addArgument("-f"); cmdLine.addArgument(input.getAbsolutePath()); LOG.trace("Executing: {}", cmdLine); DefaultExecutor exec = new DefaultExecutor(); exec.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); exec.setWatchdog(watchdog); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); exec.setStreamHandler(streamHandler); int exitValue = exec .execute(cmdLine, EnvironmentUtils.getProcEnvironment()); return outputStream.toString("UTF-8"); }
private String computePoT(File input) throws IOException, TikaException { CommandLine cmdLine = new CommandLine("pooled-time-series"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); cmdLine.addArgument("-f"); cmdLine.addArgument(input.getAbsolutePath()); LOG.fine("Executing: " + cmdLine); DefaultExecutor exec = new DefaultExecutor(); exec.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); exec.setWatchdog(watchdog); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); exec.setStreamHandler(streamHandler); int exitValue = exec .execute(cmdLine, EnvironmentUtils.getProcEnvironment()); return outputStream.toString("UTF-8"); }
public boolean run(String args) { String cli = executable.getAbsolutePath() + " " + args; System.out.println(">> " + cli); CommandLine parse = CommandLine.parse(cli); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); try { return executor.execute(parse) == 0; } catch (IOException e) { e.printStackTrace(); return false; } }
CommandLine cmdLine = new CommandLine("AcroRd32.exe"); cmdLine.addArgument("/p"); cmdLine.addArgument("/h"); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(1); int exitValue = executor.execute(cmdLine);
static String deviceName = "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920"; public static void main(String[] args) throws InterruptedException, ExecuteException, IOException { DesiredCapabilities capabilities = new DesiredCapabilities(); DefaultExecutor executor = new DefaultExecutor(); DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player"); launchEmul.addArgument("--vm-name"); launchEmul.addArgument("\""+deviceName+"\""); executor.setExitValue(1); executor.execute(launchEmul, resultHandler); Thread.sleep(40); capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 API 19 - 1080x1920"); capabilities.setCapability("platformVersion", "4.3"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("app","D:/SOFTWARES/Apks/GOA.apk"); driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities); System.out.println("SetUp is successful and Appium Driver is launched successfully"); }
@Test public void setupSh_should_have_error_with_no_argument() throws Exception { //given CommandLine oCmdLine = PlatformSetupTestUtils.createCommandLine(); DefaultExecutor oDefaultExecutor = PlatformSetupTestUtils.createExecutor(distFolder); oDefaultExecutor.setExitValue(1); //when int iExitValue = oDefaultExecutor.execute(oCmdLine); //then assertThat(iExitValue).isEqualTo(1); }
public void execute(CommandLine cmd, Map<String, String> env) { try { for (ExecutionResponseListener handler : listeners) { handler.executionAboutToStart(); } Logger.debug("executing command using executable: " + cmd.getExecutable()); executor.setExitValue(0); executor.execute(cmd, env, handler); for (ExecutionResponseListener handler : listeners) { handler.executionStarted(); } handler.waitFor(); } catch (Exception e) { for (ExecutionResponseListener handler : listeners) { handler.executionFailed("", e); } } }