Re: Send a keys to Runtime.exec process
Posted By:
Anonymous
Posted On:
Monday, June 19, 2006 05:10 PM
check example 11-6 Example 11-6. Detecting the arrow keys
at http://www.tldp.org/LDP/abs/html/internal.html
That program, even though it just check for arrow keys, you can modify it echo ctrl+n key combination. That should give you the character code for ctrl+n key. Once you get that, try passing to the output stream of your program. I am hoping your process is coded to accept input.
Re: Send a keys to Runtime.exec process
Posted By:
Anonymous
Posted On:
Monday, June 19, 2006 04:55 PM
Sorry not a perfect solution, but i would suggest write a simple java program which accepts input from the console. Then press ctrl+n key and using read method of the input stream, check the byte value. Whatever that value would be, pass the same to the out stream in your code
Process p = Runtime.getRuntime().exec("run.sh");
PrintWriter out =new PrintWriter( p.getOutputStream());
//send the ctl+n key to the process
int key = ctl+n;
out.println( key ); // pass the byte value of ctrl+n found from the above java program
out.flush();