Runtime exec/Java Main classloading console hijacking help

S

sublimate

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
 
D

Daniel Pitts

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top