I am trying to run a bat file which invokes a Java class, I want to continue interacting with command window by providing inputs and reading output from command window. But I am only able to read the first line of the command prompt and not aware how to interact with it further. on executing batch file it prompts us for a file name, once file name entered, it ask for other details
Tried using process builder and plexus util, I am not able to figure out how to run the second command after executing first one.
The below images is if I do manually, first it prompts me for file directory,
Then it prompts me for date
Tried using the below code
public class plexus {
public plexus() { String batfile = "regression-test-runner-steadfast.bat"; String directory = "C:\Dev\temp\IOS-automation-test\Steadfast-UAT-Regression-Test-Runner-Client-dist"; try { runProcess(batfile, directory); } catch (CommandLineException e) { e.printStackTrace(); } } public void runProcess(String batfile, String directory) throws CommandLineException { Commandline commandLine = new Commandline(); File executable = new File(directory + "/" +batfile); commandLine.setWorkingDirectory(directory); commandLine.setExecutable(executable.getAbsolutePath()); commandLine.createArg().setValue("C:\Users\U399526\Desktop\SVU_XML\Scenario 1"); WriterStreamConsumer systemOut = new WriterStreamConsumer( new OutputStreamWriter(System.out)); WriterStreamConsumer systemErr = new WriterStreamConsumer( new OutputStreamWriter(System.out)); int returnCode = CommandLineUtils.executeCommandLine(commandLine, systemOut, systemErr); if (returnCode != 0) { System.out.println("Something Bad Happened!"); } else { System.out.println("Taaa!! ddaaaaa!!"); }; } public static void main(String[] args) { new plexus(); }
}