Hey guys,
Somewhat complicated question, soI hope I explain this right. I'm creating a JSP front end that will run some commands behind the scenes. Now, the command works like this:
1) Type in the command itself, with parameters
2) Type in your username
3) Type in your password
4) Type in a comment
The information in 2-4 CANNOT be included in the original command, sadly. This is by design as this functionality was originally intended to be strictly user driven and not script driven.
What I'm doing is moving parameters 2-4 to a web front end so that the user can type them in there, and then the JSP will run the command and pass along the provided parameters to a shell.
Now... How can I do this in Java? I'm using Runtime/Process objects presently, but obviously the process hangs when the command asks for the username, obviously. Is there another means to, essentially, simulate user interaction with the command line via Java? Is there a way I can "inject" data into the current process that is essentially sitting and waiting for user interaction?
I've been banging my head against the wall all morning, so I thought I'd ask here as there some to be some Java gurus afoot.
Posts
The getOutputStream() method on Process will be giving you the equivalent of stdout.
You should be able to write any data that you need to on the process's InputStream and read any data out from the OutputStream.
I will try the Standard In method, I hadn't thought of that.