开发者

running external commands with control over the input/output in jython 2.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开发者_JAVA技巧 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!!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜