Runtime exec/Java Main classloading console hijacking help

Discussion in 'Java' started by sublimate@gmail.com, Feb 28, 2007.

  1. Guest

    Ok here's my problem:
    I have a java program, that I don't have class to.

    This java program, once started, sets up a command line for itself;
    Once the command line is there, I have to give it a command to fully
    start, and then i have to send it a password.

    At this point it binds some ports and runs along happily.
    The command line stays open in case I want give it status commands, or
    check its config or any other number of admin/health check tasks.


    What I want to do, is use either runexec, or exec it as a thread from
    a java program to do the following:
    Start it
    send the second start command to the command line
    send the password command to finish the start
    give the command line back to the user so they can interact with it.

    This is on windows btw. In fact on windows I have an intermediate
    sol'n.
    I setup a batch file to do a java class arguments <
    file.with.start.and.password

    which will start the program and pipe the commands form the file, but
    then it doesn't let keyboard interaction with the command line since
    its reading stdin from the file

    I tried runexec to do what i wanted but I couldn't get the timeing of
    the input/output/error streams to the process correct, ie waiting for
    the programs command prompt to init so i could send the second start/
    password, and I couldn't figure out if i could swap the intput stream
    from a file to the keyboard after it was fully started.

    When I load the program as a java class, and start it as a thread I
    can't get access to the streams either. I thought with that setting i
    might be able to do a piped stream to enable me to swap them around
    but that doesn't seem like it can work either.

    Thanks
     
    , Feb 28, 2007
    #1
    1. Advertising

  2. Daniel Pitts Guest

    On Feb 28, 10:38 am, wrote:
    > Ok here's my problem:
    > I have a java program, that I don't have class to.
    >
    > This java program, once started, sets up a command line for itself;
    > Once the command line is there, I have to give it a command to fully
    > start, and then i have to send it a password.
    >
    > At this point it binds some ports and runs along happily.
    > The command line stays open in case I want give it status commands, or
    > check its config or any other number of admin/health check tasks.
    >
    > What I want to do, is use either runexec, or exec it as a thread from
    > a java program to do the following:
    > Start it
    > send the second start command to the command line
    > send the password command to finish the start
    > give the command line back to the user so they can interact with it.
    >
    > This is on windows btw. In fact on windows I have an intermediate
    > sol'n.
    > I setup a batch file to do a java class arguments <
    > file.with.start.and.password
    >
    > which will start the program and pipe the commands form the file, but
    > then it doesn't let keyboard interaction with the command line since
    > its reading stdin from the file
    >
    > I tried runexec to do what i wanted but I couldn't get the timeing of
    > the input/output/error streams to the process correct, ie waiting for
    > the programs command prompt to init so i could send the second start/
    > password, and I couldn't figure out if i could swap the intput stream
    > from a file to the keyboard after it was fully started.
    >
    > When I load the program as a java class, and start it as a thread I
    > can't get access to the streams either. I thought with that setting i
    > might be able to do a piped stream to enable me to swap them around
    > but that doesn't seem like it can work either.
    >
    > Thanks


    Look at ProcessBuilder
    <http://java.sun.com/j2se/1.5.0/docs/api/java/lang/
    ProcessBuilder.html>
    It gives you access to the streams.
     
    Daniel Pitts, Mar 1, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Mangeng

    Tomcat classloading

    Michael Mangeng, Jan 22, 2004, in forum: Java
    Replies:
    4
    Views:
    7,517
    Michael Mangeng
    Jan 23, 2004
  2. Hal Vaughan
    Replies:
    11
    Views:
    1,124
    Gordon Beaton
    May 22, 2006
  3. Hans Georg Frey

    Runtime.exec and MS-Console-window

    Hans Georg Frey, Jun 19, 2006, in forum: Java
    Replies:
    2
    Views:
    1,162
    Hans Georg Frey
    Jun 19, 2006
  4. asaguden

    static classloading issue...

    asaguden, Feb 15, 2007, in forum: Java
    Replies:
    2
    Views:
    314
    Daniel Pitts
    Feb 17, 2007
  5. Sergey Sheypak

    Newbee question. Runtime classloading

    Sergey Sheypak, Feb 11, 2010, in forum: Ruby
    Replies:
    6
    Views:
    138
    Xavier Noria
    Feb 11, 2010
Loading...

Share This Page