Hey guys,
I've a little problem. I want bash running from within JAVA code.
i.e. The output of bash code must be displayed in my java program and
the input given to my JAVA code must be given to the input of bash. Can
anybody give me a pure JAVA solution (no JNI plz).
I tried the following:
Process prog;
prog=Runtime.getRuntime().exec("bash");
//Now I can get the IN OUT and ERR streams by the following:
InputStream In=prog.getInputStream();
OutputStream Out=prog.getOutputStream();
OutputStream Err=prog.getErrorStream();
//I can redirect my own In,Out and Err streams like this
System.setIn(<InputStream>);
System.setOut(<OutputStream>);
System.setErr(<ErrorStream>);
I've tried to achieve this using a combination of the above but in
vain. Any help or hints are welcome. Thanx in advance.