stdin & stdout of child process

G

Guest

I want from my java app to run this shell command (as child process):

php -n my_script.php

I want to create the stdin of child process from a string in my app
(e.g. String stdin_in_child).

I want to retrieve the stdout of child process (when it finished) in a
string in my app (e.g. String stdout_from_child).


I see the ProcessBuilder and Process but I failed to create a working
piece of code.

Can you help me with a URL or a simple piece of code?


Special thanks
 
R

Roedy Green

I see the ProcessBuilder and Process but I failed to create a working
piece of code.

Can you help me with a URL or a simple piece of code?

See http://mindprod.com/jgloss/exec.html
There is an example. I have not done an example with four threads.
For help on that see http://mindprod.com/jgloss/thread.html

If you can do lock step read/write with the child, you can get away
with one thread.

Just read and write the streams in the standard ways that
http://mindprod.com/applets/fileio.html
will show you.
 
R

Raymond DeCampo

I want from my java app to run this shell command (as child process):

php -n my_script.php

I want to create the stdin of child process from a string in my app
(e.g. String stdin_in_child).

I want to retrieve the stdout of child process (when it finished) in a
string in my app (e.g. String stdout_from_child).


I see the ProcessBuilder and Process but I failed to create a working
piece of code.

Can you help me with a URL or a simple piece of code?

Why don't you post what you and in what ways it fails to measure up?

Ray
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top