Pre process user input on a process. Follow
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?
Please sign in to leave a comment.
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.
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?
I have the same problem, too. Is there any listener can get the stdin?
Cannot find simple solution, probably there is no API for it at all.