Running a script python from JAVA

Alain saraz at videotron.ca
Thu Feb 3 14:08:24 EST 2000


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 code:

private void runPython(String fileName, String aDevice) { try { Process
process; Runtime runtime = Runtime.getRuntime(); String os =
System.getProperty( "os.name" ); if ( os.equals( "Windows 95" )) { String
cmd = "start python " + fileName; process=runtime.exec(cmd); } else if
 os.equals( "Windows NT" )) { String cmd = "cmd /C \"start python " +
fileName + "\""; runtime.exec( cmd ); } } catch (IOException e)
 writeToLogFile("Telnet to: "+aDevice+" failled: "+e.getMessage()); } }

Is there someone have a solution?

Thanks,

Alain







More information about the Python-list mailing list