2

How can I read from output PIPE multiple times without using process.communicate() as communicate closes the PIPE after reading the output but I need to have sequential inputs and outputs.

For example,

1) process.stdin.write('input_1')

2) After that, I need to read the output PIPE (how can I accomplish that without using communicate as it closes the PIPE) and then give another input as

3) process.stdin.write('input_2')

4) And then read the output of step 3

But if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed.

Kindly help please.

4

2 回答 2

1

flush() stdin, then read() stdout.

于 2012-07-09T05:06:30.277 回答
0

Instead of process.communicate(), use process.stdout.read()

于 2012-07-09T05:06:45.157 回答