I have a shell script running through a process runtime on Java. This Shell Script only stops when you hit CTRL+C Right now I catch the InputStream from the script in a JTextArea. but I can't send CTRL+C.
When you run CTRL+C on a Shell Konsole the script stops and sends back information. and this information is the one that I Can't Catch.
So How can I Send CTRL+C Through Process runtime? How can I catch the Inputstream from CTRL+C?
File dirw = new File("/home/mydir/sh/");
Runtime runtime = Runtime.getRuntime();
Process process = null;
process = runtime.exec("./start_test.sh", null, dirw);
OutputStream outp = new OutputStream(process.getOutputStream());
InputStreamReader isr = new InputStreamReader(process.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
int cont = 1;
while ((line = br.readLine()) != null) {
jtextarea.append("LineOK " + line + "\n");
if( cont == 10) {
outp.write(3); //sending Ctrl+C
outp.flush();
cont =0;
}
cont ++;
}