use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.
the class NucleusTestUtils method cmdWithOutput.
public static NadminReturn cmdWithOutput(final File cmd, final int timeout, final String... args) {
List<String> command = new ArrayList<String>();
command.add(cmd.toString());
command.add("--echo");
command.addAll(Arrays.asList(args));
ProcessManager pm = new ProcessManager(command);
// the tests may be running unattended -- don't wait forever!
pm.setTimeoutMsec(timeout);
pm.setEcho(false);
pm.setEnvironment(envp);
int exit;
String myErr = "";
try {
exit = pm.execute();
} catch (ProcessManagerTimeoutException tex) {
myErr = "\nProcessManagerTimeoutException: command timed out after " + timeout + " ms.";
exit = 1;
} catch (ProcessManagerException ex) {
ex.printStackTrace();
myErr = "\n" + ex.getMessage();
exit = 1;
}
NadminReturn ret = new NadminReturn(exit, pm.getStdout(), pm.getStderr() + myErr, args[0]);
write(ret.outAndErr);
return ret;
}
use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.
the class WindowsService method install.
private void install() throws ProcessManagerException {
if (info.dryRun) {
try {
// dry-run not so useful on Windows. Very useful on UNIX...
xmlFileCopy = Strings.get("xmlfiledump") + FileUtils.readSmallFile(targetXml);
} catch (IOException ex) {
// oh well....
}
if (!targetWin32Exe.delete())
dryRun("Dry Run error: delete failed for targetWin32Exe " + targetWin32Exe);
if (!targetXml.delete())
dryRun("Dry Run error: delete failed for targetXml " + targetXml);
} else {
ProcessManager mgr = new ProcessManager(targetWin32Exe.getPath(), "install");
mgr.setEcho(false);
mgr.execute();
int ret = mgr.getExitValue();
if (ret != 0)
throw new RuntimeException(Strings.get("windows.services.install.bad", "" + ret, mgr.getStdout(), mgr.getStderr()));
trace("Install STDERR: " + mgr.getStderr());
trace("Install STDOUT: " + mgr.getStdout());
}
}
use of com.sun.enterprise.universal.process.ProcessManager in project Payara by payara.
the class SetupLocalDcom method executeCommand.
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
try {
List<String> cmds = new ArrayList<String>();
cmds.add(CPP_APP.getAbsolutePath());
if (verbose)
cmds.add("--verbose");
ProcessManager pm = new ProcessManager(cmds);
pm.execute();
int ret = pm.getExitValue();
if (verbose || ret != 0)
logger.info(pm.getStdout() + pm.getStderr());
return ret;
} catch (ProcessManagerException ex) {
throw new CommandException(ex);
}
}
Aggregations