Pre process user input on a process.

Answered

I would like to gather the data a user enters into a running process. If the process prompts "Enter your name: "

I can get that information by adding a ProcessListener to the process handler, but how do I get the user input, i.e, "Enter your name: John Smith" (I would like to get "John Smith")

Can I listen to stdin for the process somehow?

 

4 comments
Comment actions Permalink

There is no direct API for it but still you can try to use ((BaseProcessHandler)processHandler).getProcess().getInputStream()

P.S. Sorry, this stream is actually OUTPUT stream (stdout) of running process.

0
Comment actions Permalink

Sorry for the late follow-up,

Where would I be able to access the InputStream? 

I currently try to get input stream data during the ProcessEvent onTextAvailable inside a custom ProcessListener, but I get errors that the buffer is closed.

And once I do, would I need to reinsert characters to pass the expected behavior back to PyCharm? Does reading characters remove them from the stream?

0
Comment actions Permalink

I have the same problem, too. Is there any listener can get the stdin?

0
Comment actions Permalink

Cannot find simple solution, probably there is no API for it at all.

0

Please sign in to leave a comment.