Pre process user input on a process.

已回答

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?

 

0
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

0

请先登录再写评论。