The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Another Java question

saint2esaint2e Registered User regular
edited April 2007 in Help / Advice Forum
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.

banner_160x60_01.gif
saint2e on

Posts

  • mindlarmindlar Registered User regular
    edited April 2007
    The getInputStream() method on Process should give you back what is effectively stdin if you were running your app from a shell.

    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.

    mindlar on
  • DrFrylockDrFrylock Registered User regular
    edited April 2007
    Yep, that's probably the easiest way. You could have the process open a TCP socket listener and send data to it that way as well, or you could use RMI or something, but the input streams are already there.

    DrFrylock on
  • PhilodoxPhilodox Registered User regular
    edited April 2007
    I don't know if this is something you're doing for school, but there's probably a better way to do it as opposed to sending text entered from a jsp page to a console application.

    Philodox on
    That's a Freudian mansex if I ever cocked one.
    twinsbanneroq0.jpg
  • saint2esaint2e Registered User regular
    edited April 2007
    Nah, I'm essentially creating a wrapper around our company's tool. Unfortunately the tool was designed specifically to only allow user interaction to provide the details, so I'm kinda breaking the tool's original intentions.

    I will try the Standard In method, I hadn't thought of that.

    saint2e on
    banner_160x60_01.gif
Sign In or Register to comment.