I've an exe program placed on shared location. It doesn't take any arguments while starting. When it is launched in a command window, it displays a help menu with list of commands that can be executed with it and ends with >
expecting an input command. I need to execute one particular command called TRIGGER
from that list. So far this is what I've but it fails completely. It neither displays the output from the process nor takes the input command trigger
from the stream.
public void execute(){
String cmd = "\\\\sharedLocation\\server\\adm.exe";
p = Runtime.getRuntime().exec(cmd);
InputStream in = p.getInputStream();
OutputStream out = p.getOutputStream();
BufferedReader br= new BufferedReader(new InputStreamReader(in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
bw.write("TRIGGER");
bw.flush();
String output = "";
while (!output.endsWith(">")) {
System.out.println("in loop");
output = output + br.readLine();
}
System.out.println("Out"+output);
out.close();
p.waitFor();
}
EDIT : adm.exe is launched by this program but it appears that adm.exe is a blocking process. It fails to println the "in loop" statement. However when I open up windows task manager and kill the adm.exe process tree, this shows up on the console
in loopnull
in loopnullnull
in loopnullnullnull
in loopnullnullnullnull
in loopnullnullnullnullnull
in loopnullnullnullnullnullnull
in loopnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
in loopnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
Outnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull