in SamplesV1/CustomizedJavaOnHDInsight/HDInsight-ADF/src/com/adf/jobonhdi/JobOnHdiLauncher.java [69:112]
public int submitJob() throws Exception
{
int exitStatus = 0;
String executionCmd = cmd.getOptionValue(COMMAND);
// download files
if (cmd.hasOption(FILES))
{
downloadFiles(cmd.getOptionValue(FILES), this.isWindowsOs);
}
System.out.println("Start executing : " + executionCmd);
List<String> commands = new ArrayList<String>();
if (isWindowsOs)
{
commands.add("cmd");
commands.add("/c");
}
else
{
commands.add("/bin/sh");
commands.add("-c");
}
commands.add(executionCmd);
ProcessBuilder pb = new ProcessBuilder(commands);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
Process cmdProcess = pb.start();
exitStatus = cmdProcess.waitFor();
if (exitStatus != 0)
{
System.err.println("Error while executing command : " + executionCmd);
}
else
{
System.out.println("Command succeeded!");
}
return exitStatus;
}