public static String extractClassPathUsingMvnV2(String projectRoot, boolean installIt) throws IOException, InterruptedException { if (installIt) { // Prior installation to produce full pom (in case of multi modules) System.out.println("[MAVEN] Installing module...."); ProcessBuilder proc0 = new ProcessBuilder("mvn", "install"); proc0.directory(new File(projectRoot)); proc0.start().waitFor(); } System.out.println("[MAVEN] Dependencies extraction..."); // Extract dependencies ProcessBuilder proc1 = new ProcessBuilder("mvn", "dependency:build-classpath"); proc1.directory(new File(projectRoot)); Process start = proc1.start(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(start.getInputStream())); String s = null; String cp = ""; while ((s = stdInput.readLine()) != null) { if (!s.startsWith("[") && !s.contains(" ") && !s.contains("http://") && !s.contains("https://")) { cp += (cp.length() == 0 ? "" : ":") + s; } } return cp; }
public static Process executeLocal(String[] cmdArray, File ifileDir) { // System.out.println("local execution!" + " " + Arrays.toString(cmdArray) ); ProcessBuilder processBuilder = new ProcessBuilder(cmdArray); Map<String, String> env = processBuilder.environment(); if (!env.containsKey(OCSSW_ROOT_VAR) && OCSSW.isOCSSWExist()) { env.put(OCSSW_ROOT_VAR, OCSSW.getOcsswEnv()); } if (ifileDir != null) { processBuilder.directory(ifileDir); } else { processBuilder.directory(getDefaultDir()); } Process process = null; try { process = processBuilder.start(); int exitValue = process.waitFor(); } catch (Exception e) { VisatApp.getApp() .showErrorDialog( "OCSSW execution error from SeaDAS application! \n" + cmdArray[0] + " program is not executed correctly."); e.printStackTrace(); } return process; }
@Override protected void onBeforeProcessStart( ProcessBuilder processBuilder, NodejsConfig config, IRuntimeConfig runtimeConfig) { super.onBeforeProcessStart(processBuilder, config, runtimeConfig); processBuilder.directory(new File(config.getWorkingDirectory())); }
@Override public void open(String repositoryPath) { FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder(); try { repository = repositoryBuilder .setGitDir(new File(repositoryPath)) .readEnvironment() // read git environment variables .findGitDir() .build(); } catch (IOException e) { throw new VisMinerAPIException(e.getMessage(), e); } git = new Git(repository); revWalk = new RevWalk(repository); treeWalk = new TreeWalk(repository); reader = repository.newObjectReader(); processBuilder = new ProcessBuilder(); processBuilder.directory(new File(repository.getDirectory().toString())); commands = Arrays.asList("git", "log", "--numstat", "--oneline", "--max-count=1", ""); this.repositoryPath = repository.getWorkTree().getAbsolutePath(); }
/** * Method description * * @return * @throws IOException */ protected Process createProcess() throws IOException { if (logger.isDebugEnabled()) { StringBuilder cmd = new StringBuilder(); for (String c : command) { cmd.append(c).append(" "); } logger.debug("start external process '{}'", cmd.toString()); } ProcessBuilder processBuilder = new ProcessBuilder(command); if (workDirectory != null) { processBuilder = processBuilder.directory(workDirectory); } Map<String, String> env = processBuilder.environment(); if (useSystemEnvironment) { env.putAll(System.getenv()); } if (environment != null) { env.putAll(environment); } return processBuilder.redirectErrorStream(true).start(); }
@Override public CommandRunner.CommandOutput runCommandAndWaitForExit( File workingDir, List<String> arguments) throws IOException, InterruptedException { File binary = new File(arguments.get(0)); if (!binary.exists()) { logger.error("Binary {} does not exists, fix your configuration!", binary.getAbsolutePath()); return createErrorCommandOutput(); } if (!binary.canExecute()) { logger.error( "Binary {} can't be executed, fix your configuration!", binary.getAbsolutePath()); return createErrorCommandOutput(); } ProcessBuilder pb = new ProcessBuilder(arguments); pb.directory(workingDir); Process process = pb.start(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); ByteArrayOutputStream stdout = new ByteArrayOutputStream(); CommandRunnerImpl.StreamGobbler sgerr = new CommandRunnerImpl.StreamGobbler(process.getErrorStream(), stderr); CommandRunnerImpl.StreamGobbler sgout = new CommandRunnerImpl.StreamGobbler(process.getInputStream(), stdout); sgerr.start(); sgout.start(); int exitCode = process.waitFor(); sgerr.join(); sgout.join(); CommandRunner.CommandOutput result = new CommandRunner.CommandOutput(stdout.toByteArray(), stderr.toByteArray()); result.setExitCode(exitCode); return result; }
public void createMatchTable() throws IOException, InterruptedException { addReport("Matching keypoints started"); // File matchTable = new File(FileHelper.mergePath(imageDirectory, // keypointMatchTableFilename)); // // if(matchTable.exists()) { // addReport("Match table \""+keypointMatchTableFilename+"\" exists, therefore skip // matching"); // return; // } ProcessBuilder pb = new ProcessBuilder( keypointMatcherPath, FileHelper.mergePath(imageDirectory, imageListKeysFilename), FileHelper.mergePath(imageDirectory, keypointMatchTableFilename)); pb.directory(new File(imageDirectory)); Process p = pb.start(); addReport(p.getInputStream(), p.getErrorStream()); if (p.waitFor() != 0) { addReport("Matching keypoints error"); stop(); } }
private static void run(String commands, String direct_out_to) { Process p; ArrayList<String> data = new ArrayList<String>(); // try{ String[] command = commands.split("\\s+"); try { ProcessBuilder builder2 = new ProcessBuilder(command); builder2.directory(new File(_jobpath)); p = builder2.start(); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readLine()) != null) { if (direct_out_to == null) { System.out.println(line); } else { data.add(line); } } p.waitFor(); Util.writeToFile(data, direct_out_to); } catch (Exception e) { System.out.println(e.getMessage()); } }
private boolean pack200(final File sourceFile, final File targetFile) throws IOException { JarFile jarFile = new JarFile(sourceFile); try { if (isSigned(jarFile)) { return false; } try { String pack200Executable = new File(System.getProperty("java.home"), "bin/pack200" + (isWindows() ? ".exe" : "")) .getAbsolutePath(); ProcessBuilder pb = new ProcessBuilder( pack200Executable, targetFile.getAbsolutePath(), sourceFile.getAbsolutePath()); pb.directory(sourceFile.getParentFile()); int result; Process process = pb.start(); result = process.waitFor(); process.destroy(); return result == 0; } catch (InterruptedException e) { return false; } finally { if (targetFile.exists()) { targetFile.setLastModified(sourceFile.lastModified()); } } } finally { jarFile.close(); } }
public static Process executeRemote(String[] cmdArray, File ifileDir) { Gson gson = new Gson(); String json = gson.toJson(cmdArray); JsonParser parser = new JsonParser(); JsonArray array = parser.parse(json).getAsJsonArray(); ProcessBuilder processBuilder = new ProcessBuilder(cmdArray); Map<String, String> env = processBuilder.environment(); if (environment != null) env.putAll(environment); if (ifileDir != null) { processBuilder.directory(ifileDir); } else { // processBuilder.directory(getDefaultDir()); } Process process = null; try { process = processBuilder.start(); } catch (IOException ioe) { } return process; }
protected void generate(StringToStringMap values, ToolHost toolHost, WsdlProject project) throws Exception { String wstoolsDir = SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null); if (Tools.isEmpty(wstoolsDir)) { UISupport.showErrorMessage("wstools directory must be set in global preferences"); return; } String wsToolsExtension = UISupport.isWindows() ? ".bat" : ".sh"; File wstoolsFile = new File(wstoolsDir + File.separatorChar + "wstools" + wsToolsExtension); if (!wstoolsFile.exists()) { UISupport.showErrorMessage("Could not find wstools script at [" + wstoolsFile + "]"); return; } ProcessBuilder builder = new ProcessBuilder(); ArgumentBuilder args = buildArgs(values, UISupport.isWindows()); builder.command(args.getArgs()); builder.directory(new File(wstoolsDir)); toolHost.run( new ToolRunner(builder, new File(values.get(OUTPUT)), values.get(SERVICE_NAME), project)); }
/** * Return bursts from a hexa frame without time advance * * @param hexaFrame frame in hexadecimal * @param fn the frame number * @param siType the System Information type (5/5ter/6) * @return String[] with all 4 bursts from the frame * @throws IOException if error while executing command */ public static String[] getBursts(String hexaFrame, String fn, String siType) throws IOException { String[] bursts = new String[6]; bursts[4] = fn; bursts[5] = siType; int i = 0; // delete Time Advance StringBuilder hexaFrameNoTA = new StringBuilder(hexaFrame); hexaFrameNoTA.setCharAt(2, '0'); hexaFrameNoTA.setCharAt(3, '0'); ProcessBuilder pb = new ProcessBuilder("./gsmframecoder", hexaFrameNoTA.toString()); pb.redirectErrorStream(true); pb.directory(Configuration.gsmFrameCoder); Process p = pb.start(); p.getOutputStream().flush(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String ligne = new String(); while ((ligne = reader.readLine()) != null) { if (ligne.length() == 114 && i < 4) { bursts[i] = ligne; i++; } } p.destroy(); p.destroyForcibly(); return bursts; }
private void launchServer(int port) throws Exception { List<String> commands = new ArrayList<>(); try { URL url = getClassLocation(XmlTransformServer.class); String path = new File(url.toURI()).getAbsolutePath(); int indexOf = path.indexOf("bin"); path = path.substring(0, indexOf + 4); File classFileLocation = new File(path); String className = XmlTransformServer.class.getName(); commands.add("java"); commands.add("-Xmx1024M"); commands.add(className); commands.add(Integer.toString(port)); ProcessBuilder builder = new ProcessBuilder(); builder.directory(classFileLocation); builder.command(commands); process = builder.start(); Thread.sleep(800); } catch (URISyntaxException ex) { throw new Exception("Unable to find XmlTransformServer class in File System. ", ex); } catch (Exception ex) { throw new Exception("Unable to launch TransformServer. ", ex); } }
protected Process startProcess(@NotNull List<String> commands) throws IOException { ProcessBuilder builder = new ProcessBuilder(commands); setupEnvironment(builder.environment()); builder.directory(myWorkDirectory); builder.redirectErrorStream(myRedirectErrorStream); return builder.start(); }
@Test @Ignore("Deactivated awaiting resolution of http://jira.sonarsource.com/browse/JC-145") public void should_run_lint_after_export_and_import_results() throws Exception { assumeTrue(AndroidTestSuite.isAtLeastPlugin1_1()); String response = exportProfile("it-profile"); File baseDir = new File("projects/SonarAndroidSample/app"); FileUtils.write(new File(baseDir, "lint.xml"), response, Charsets.UTF_8); ProcessBuilder pb = new ProcessBuilder("CMD", "/C", "gradle lint"); pb.directory(baseDir); pb.inheritIO(); Process gradleProcess = pb.start(); int exitStatus = gradleProcess.waitFor(); if (exitStatus != 0) { fail("Failed to execute gradle lint."); } SonarRunner analysis = SonarRunner.create() .setProfile("it-profile") .setProjectName("SonarAndroidSample2") .setProjectKey("SonarAndroidSample2") .setProjectVersion("1.0") .setSourceDirs("src/main") .setProjectDir(baseDir) .setProperty("sonar.android.lint.report", "lint-report-build.xml") .setProperty("sonar.import_unknown_files", "true"); orchestrator.executeBuild(analysis); Resource project = sonar.find(ResourceQuery.createForMetrics("SonarAndroidSample2", "violations")); assertThat(project.getMeasureIntValue("violations")).isEqualTo(2); }
public static Either<CommandResult> runCommand( final Context context, final String command, final File path, final List<String> arguments) { try { final List<String> commandAndArgs = new ArrayList<String>(); commandAndArgs.add(command); commandAndArgs.addAll(arguments); final ProcessBuilder pb = new ProcessBuilder(commandAndArgs); if (path != null) { pb.directory(path); } logCommand(context, pb); final Process compilation = pb.start(); final ConsumeStream result = ConsumeStream.start(compilation.getInputStream(), context); final ConsumeStream error = ConsumeStream.start(compilation.getErrorStream(), context); final int exitCode = compilation.waitFor(); result.join(); error.join(); if (result.exception != null) { return Either.fail(result.exception); } if (error.exception != null) { return Either.fail(error.exception); } return Either.success( new CommandResult(result.output.toString(), error.output.toString(), exitCode)); } catch (IOException ex) { return Either.fail(ex); } catch (InterruptedException ex) { return Either.fail(ex); } }
protected void xcodebuildClean() throws IOSException { List<String> parameters = createXcodebuildCleanParameters(); ProcessBuilder pb = new ProcessBuilder(parameters); pb.directory(workDir); executeCommand(pb); }
/** Start a dedicated Cassandra process for this node. */ public void start() { getLog() .info( String.format( "Starting node #%s: %s:%s", mNodeId, mMyAddress, mCassandraConfiguration.getPortNativeTransport())); try { ProcessBuilder pb = new ProcessBuilder(); // Build a Java command line for running Cassandra. String javaExec = getJavaExecutable(); // Set the classpath to include all of the dependencies for this plugin (i.e., Cassandra). String classpath = getClasspath(); // Set CASSANDRA_CONF appropriately. Map<String, String> environmentVariables = pb.environment(); updateEnvironmentVariables(environmentVariables); pb.command(javaExec, "-cp", classpath, CassandraDaemon.class.getCanonicalName()); pb.directory(mRootDir); mCassandraProcess = pb.start(); // getLog().info("Successfully started node " + mNodeId); } catch (IOException ioe) { getLog().warn("Could not start Cassandra node " + mNodeId); } }
/** Run when the command is executed. */ public Object execute(ExecutionEvent event) throws ExecutionException { final String prop = System.getProperty("eclipse.home.location"); final String os = System.getProperty("os.name"); final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); if (os != null && os.toLowerCase().startsWith("win")) { if (prop != null && prop.length() > 0) try { // Fetch the Eclipse homedir final URL url = new java.net.URL(prop); final File eclipseDir = new File(url.getFile()).getCanonicalFile(); if (eclipseDir != null) { // Extract the homedir, go ../firmware_upgrade final File uploadDir = new File(eclipseDir, "firmware_upgrade"); final File uploadExe = new File(uploadDir, "VEXnetUpgrade.exe"); final ProcessBuilder builder = new ProcessBuilder(); builder.command(uploadExe.getAbsolutePath()); builder.directory(uploadDir); builder.start(); } } catch (Exception e) { error( window, "VEXnet Firmware Upgrade is missing or incorrectly configured.\n" + "The most recent version of this utility is available on the VEX Wiki."); } } else error(window, "VEXnet Firmware Upgrade only works on Windows computers."); return null; }
private void spawnWorkerAndWait(Script myWhatToDo) { String currentClassPathString = System.getProperty("java.class.path"); Set<File> classPaths = calculateClassPath(new File(System.getProperty("user.dir"))); List<String> commandLine = new ArrayList<String>(); commandLine.add(JavaEnvUtils.getJreExecutable("java")); commandLine.addAll(Arrays.asList(JVM_ARGS)); StringBuilder sb = new StringBuilder(); String pathSeparator = System.getProperty("path.separator"); for (File cp : classPaths) { sb.append(pathSeparator); sb.append(cp.getAbsolutePath()); } // copy ant libs for (String entry : currentClassPathString.split(pathSeparator)) { if (entry.indexOf("ant") >= 0) { sb.append(pathSeparator); sb.append(entry); } } commandLine.add("-classpath"); commandLine.add(sb.toString()); commandLine.add(MakeWorker.class.getCanonicalName()); try { commandLine.add(myWhatToDo.dumpToTmpFile().getAbsolutePath()); } catch (FileNotFoundException e) { throw new BuildException(e); } ProcessBuilder pb = new ProcessBuilder(JavaEnvUtils.getJreExecutable("java")); pb.command(commandLine); pb.directory(new File(System.getProperty("user.dir"))); executeProcess(pb); }
@Override public void run() { try { // File meteocalc = new // File(facade.getConstants().getMeteoOrderDir()+facade.getConstants().getMeteoOrderCommand()); String[] command = { "CMD", "/C", facade.getConstants().getImageOrderCommand(), getId().toString() }; ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.directory(new File(facade.getConstants().getImageOrderDir())); LOG.debug("ImageOrder #" + this.getId() + " prepared for execution. Starting."); Process process = processBuilder.start(); process.waitFor(); LOG.debug("ImageOrder #" + this.getId() + " finished execution"); facade.getOrderProcessor().releaseProcessor(this); String url = facade.getConstants().getMeteoOrderDir() + "OUT_IMAGES/" + getId() + "." + facade.getConstants().getImageFormat(); if (new File(url).canRead()) { setImageURL(url); setStatus(Status.READY_FOR_PICKUP); } else { throw new Exception("Image file was not created or cannot to be read"); } } catch (Exception e) { LOG.error(e); throw new RuntimeException(e); } }
public static void runFindBugs(File file, File dir) { if (FINDBUGS_JAR.getValue() != null) { TaskProgressLogger task = TaskProgressLogger.get(); task.start("Running FindBugs"); File output = new File(dir, FINDBUGS_FILE_NAME.getValue()); try { ProcessBuilder builder = new ProcessBuilder( "java", "-jar", FINDBUGS_JAR.getValue().getPath(), "-textui", "-xml", "-output", output.getPath(), file.getPath()); builder.inheritIO(); builder.directory(dir); Process process = builder.start(); process.waitFor(); task.finish(); } catch (IOException | InterruptedException e) { task.exception(e); } } }
protected void runPub( IContainer container, final MessageConsole console, List<String> args, boolean wait) { stringBuilder = new StringBuilder(); ProcessBuilder builder = new ProcessBuilder(); builder.directory(container.getLocation().toFile()); builder.redirectErrorStream(true); builder.command(args); final Process process; try { process = builder.start(); final Thread stdoutThread = new Thread( new Runnable() { @Override public void run() { try { copy(process.getInputStream(), console); } catch (IOException e) { // do nothing } } }); stdoutThread.start(); if (wait) { process.waitFor(); } } catch (IOException e) { String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toString()); console.println(message); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
private boolean runPubServe(DartLaunchConfigWrapper wrapper) { stdOut = new StringBuilder(); stdError = new StringBuilder(); IResource resource = wrapper.getApplicationResource(); console.printSeparator("Starting pub serve : " + resource.getProject().getName()); workingDir = DartCore.getApplicationDirectory(resource); List<String> args = buildPubServeCommand(); String dirName = getPubserveRootDir(workingDir, resource); if (dirName != null) { args.add(getPubserveRootDir(workingDir, resource)); } ProcessBuilder builder = new ProcessBuilder(); builder.command(args); builder.directory(workingDir.getLocation().toFile()); try { process = builder.start(); } catch (IOException e) { DartCore.logError(e); return false; } Thread stdoutThread = new Thread( new Runnable() { @Override public void run() { copyStream(process.getInputStream(), stdOut, true); } }); stdoutThread.start(); Thread stderrThread = new Thread( new Runnable() { @Override public void run() { copyStream(process.getErrorStream(), stdError, true); } }); stderrThread.start(); while (!isTerminated() && !stdOut.toString().contains(LOCAL_HOST_ADDR)) { try { Thread.sleep(200); } catch (Exception exception) { } } if (isTerminated()) { return false; } currentLaunch = wrapper; return true; }
public StreamSink createStreamSink(ServiceContext context, Flow flow) { List<String> commandList = new ArrayList<String>(); String cmd = command.evaluateString(context, flow); commandList.add(cmd); for (int i = 0; i < commandArgs.length; ++i) { String arg = commandArgs[i].evaluateString(context, flow); commandList.add(arg); } ProcessBuilder processBuilder = new ProcessBuilder(commandList); Map<String, String> environment = processBuilder.environment(); for (int i = 0; i < envVariableFactories.length; ++i) { EnvVariable envVariable = envVariableFactories[i].createEnvVariable(context, flow); environment.put(envVariable.getName(), envVariable.getValue()); } String directory = dirResolver.evaluateAsString(flow.getParameters(), flow.getRecord()); if (directory.length() > 0) { File file = new File(directory); processBuilder.directory(file); } StreamSink streamSink = new CommandSink(processBuilder, charset); return streamSink; }
protected void generate(StringToStringMap values, ToolHost toolHost, Interface modelItem) throws Exception { String wsimportDir = SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null); if (Tools.isEmpty(wsimportDir)) { UISupport.showErrorMessage( "JBossWS wstools/wsconsume directory must be set in global preferences"); return; } String wsimportExtension = UISupport.isWindows() ? ".bat" : ".sh"; File wscompileFile = new File(wsimportDir + File.separatorChar + "wsconsume" + wsimportExtension); if (!wscompileFile.exists()) { UISupport.showErrorMessage("Could not find wsconsume script at [" + wscompileFile + "]"); return; } ProcessBuilder builder = new ProcessBuilder(); ArgumentBuilder args = buildArgs(UISupport.isWindows(), modelItem); builder.command(args.getArgs()); builder.directory(new File(wsimportDir)); toolHost.run(new ProcessToolRunner(builder, "JBossWS wsconsume", modelItem)); }
public void setUpSolrFile(String url) throws Exception { if (setUpIsDone) { return; } // do the setup File testDir = (Paths.get(getClass().getResource("/" + testFile).toURI()).getParent()).toFile(); ProcessBuilder pb = new ProcessBuilder("java", "-Durl=" + url + "/update", "-jar", "post.jar", testFile); pb.directory(testDir); LOGGER.log(Level.FINE, "Starting SOLR import"); final Process command = pb.start(); LOGGER.log(Level.FINE, "Started SOLR import"); String line; BufferedReader bri = new BufferedReader(new InputStreamReader(command.getInputStream())); BufferedReader bre = new BufferedReader(new InputStreamReader(command.getErrorStream())); while ((line = bri.readLine()) != null) { LOGGER.log(Level.FINE, line); } bri.close(); while ((line = bre.readLine()) != null) { LOGGER.log(Level.FINE, line); } bre.close(); int i = command.waitFor(); assertTrue(i == 0); LOGGER.log(Level.FINE, "SOLR import DONE!"); setUpIsDone = true; }
private void execute(List<String> command2) { try { ProcessBuilder builder = new ProcessBuilder(command2); if (env.size() > 0) builder.environment().putAll(env); if (StringUtils.hasLength(workingDir)) builder.directory(new File(workingDir)); builder.redirectErrorStream(true); process = builder.start(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream())); try { String line; while ((line = stdInput.readLine()) != null) { System.out.println(line); } process.waitFor(); } finally { stdInput.close(); } } catch (IOException e) { throw new AssertionError(e); } catch (InterruptedException e) { throw new AssertionError(e); } }
public Process createProcess() throws ExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Executing [" + getCommandLineString() + "]"); } List<String> commands; try { checkWorkingDirectory(); if (StringUtil.isEmptyOrSpaces(myExePath)) { throw new ExecutionException( IdeBundle.message("run.configuration.error.executable.not.specified")); } commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList()); } catch (ExecutionException e) { LOG.warn(e); throw e; } try { ProcessBuilder builder = new ProcessBuilder(commands); setupEnvironment(builder.environment()); builder.directory(myWorkDirectory); builder.redirectErrorStream(myRedirectErrorStream); return builder.start(); } catch (IOException e) { LOG.warn(e); throw new ProcessNotCreatedException(e.getMessage(), e, this); } }
protected Boolean process(String command) { File script; String suffix = ".sh"; if (SystemUtils.IS_OS_WINDOWS) { suffix = ".bat"; } if ((script = setData(command, suffix)) == null) { return false; } script.setExecutable(true); // starts and wait for the process ProcessBuilder pb = new ProcessBuilder("." + File.separator + script.getName()); pb.directory(new File(script.getAbsolutePath().replace(script.getName(), File.separator))); try { Process p = pb.start(); p.waitFor(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuilder builder = new StringBuilder(); String line = null; while ((line = br.readLine()) != null) { builder.append(line); builder.append(System.getProperty("line.separator")); } String result = builder.toString(); log.info(result); } catch (IOException | InterruptedException e) { LogHandler.writeStackTrace(log, e, Level.SEVERE); return false; } // deletes the script script.delete(); return true; }