1

I have an application using jython2.1 and I need to run external applications, (lets say some .exe for now). I also need to capture the input and output such as logs from that program.

Jython 2.1 seems to not have the support for popen().

ANy idea how I do that , apart from depending on standard Java libraries? Just trying to explore different ways of doing that. Any small suggestion would be of great help for me Guys!!

2 Answers 2

1

You can just use Java's classes that do this.

from java.lang import Runtime
process = Runtime.getRuntime().exec("ls -l")
output = process.getInputStream() # process' output is our input
# read output somehow, while the process is generating it
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this one, and it works perfect for me. Except for the fact like if I run say Notepad.exe, the process opens the notepad but never closes until I close notepad. Is there anyway that I can get the control from the child program when it successfully ran?
0

Any reason you're using jython 2.1? I mean, it's ancient - it was released 10 years ago - you can't even find download/documentation for it anymore.

10 years is a long time in software development.

Newest version seems to support the subprocess module, which is the current python way of executing a subprocess and capturing output.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.