Running a python script from JAVA, with correct indentation

Jon K Hellan hellan at acm.org
Sat Feb 5 11:29:11 CET 2000


"Alain" <saraz at videotron.ca> writes:

> Hi,
> 
> I'm trying to run a script from a file. The script is written in python. The
> script is a telnet session between a router and a computer. If I run the
> script from a DOS prompt window, everything is good. But if I start the
> script from my program, using a Runtime object, there's a problem. The
> communication between the router and the computer is stop, even if the
> telnet session is still open. Here's the JAVA code:

You're running Win95 or Win98, right? 

In that case, Java programs are unable to capture output from DOS
commands. A plausible explanation can be found in the NT Emacs FAQ:

http://www.cs.washington.edu/homes/voelker/ntemacs.html#subproc

> Programs reading input hang
> 
> Programs that explicitly use a handle to the console ("CON" or
> "CON:") instead of stdin and stdout cannot be used as subprocesses
> to Emacs, and they will also not work in shell-mode (the default ftp
> clients on Win95 and NT are examples of such programs). There is no
> convenient way for either Emacs or any shell used in shell-mode to
> redirect the input and output of such processes from the console to
> input and output pipes.

Java apparently uses the same technique as Emacs to communicate with
subprocesses. Emacs on Win95 cannot capture output from an inferior
Python, so it's no surprise that Java cannot, either.

> Is there someone have a solution? 

Use jpython?

It should also be possible to modify the Python interpreter. But if
jpython can accomplish your task, use it!

Jon



More information about the Python-list mailing list