1

We have an app named app.exe which in turn is a wrapper for a java.exe for the installanywhere launcher. Suppose we have a python script a.py which calls app.exe which then spawns the java.exe process, how do we capture the interactive outputs and inputs between a.py and java.exe

Can Popen do that ? Are there simple examples we could read more to follow ? Can pexpect be used in this scenario too ?

Thanks

chz
  • 355
  • 1
  • 7
  • 21

1 Answers1

2

That's possible if your a.exe redirects its own stdin to java.exe stdin and java.exe stdout to its own stdout.

Have a look at subprocess.Popen. There are 2 optional arguments: stdin controlling subproces's standard input and stdout, which controls subproces's standard output.

Maksym Polshcha
  • 18,030
  • 8
  • 52
  • 77