/** * Runs an executable and waits until the executable finishes or until * a certain amount of time has passed (timeout). * * @param cmd The system command to execute. E.g. "/bin/sh some-script.sh arg1 arg2" * @param stdoutFileName specifies the file where stdout of the executable is redirected to. * @param timeout A timeout in seconds. If the executable is still running after * <code>timeout</code> seconds, the executable is stopped and this method returns. * @return exit-code of the executable. */ public static int run(final String cmd, final String stdoutFileName, final int timeout) { return run(cmd, stdoutFileName, timeout, null); }
public static int run(final String[] cmdArgs, final String stdoutFileName, final int timeout, final String workingDirectory) { final ExternalExecutor myExecutor = new ExternalExecutor(cmdArgs, stdoutFileName, workingDirectory); return waitForFinish(myExecutor, timeout); }
/** * Runs an executable and waits until the executable finishes or until * a certain amount of time has passed (timeout). * * @param cmd The system command to execute. E.g. "/bin/sh some-script.sh arg1 arg2" * @param stdoutFileName specifies the file where stdout of the executable is redirected to. * @param timeout A timeout in seconds. If the executable is still running after * <code>timeout</code> seconds, the executable is stopped and this method returns. * @param workingDirectory the working directory to be used when calling the command * @return exit-code of the executable. */ public static int run(final String cmd, final String stdoutFileName, final int timeout, final String workingDirectory) { final ExternalExecutor myExecutor = new ExternalExecutor(cmd, stdoutFileName, workingDirectory); return waitForFinish(myExecutor, timeout); }
public static int run(final String[] cmdArgs, final String stdoutFileName, final int timeout) { return run(cmdArgs, stdoutFileName, timeout, null); }
@Override public boolean invoke() { String cmd = exePath + " " + outFileRoot + modulePrefix + ExternalConfigFileName; String logfilename = controler.getIterationFilename(currentIteration, modulePrefix + "stdout.log"); return (ExeRunner.run(cmd, logfilename, 3600) == 0); } };
protected void runExe(final String iterationConfigFile) throws FileNotFoundException, IOException { String cmd = this.executable + " " + iterationConfigFile; log.info("running command: " + cmd); Gbl.printMemoryUsage(); String logfileName = this.controlerIO.getIterationFilename(this.getIterationNumber(), "mobsim.log"); int timeout = this.simConfig.getExternalTimeOut() ; int exitcode = ExeRunner.run(cmd, logfileName, timeout); if (exitcode != 0) { throw new RuntimeException("There was a problem running the external mobsim. exit code: " + exitcode); } }
ExeRunner.run(cmd, stdoutFileName, timeout, config.controler().getOutputDirectory() + actType + "/" + mode);