executing a python script on windows using java Runtime.exec -
i have python script runs on windows , uses win32 extensions , wmi information. if run script using command line, executes perfectly. but, if try run same script using java runtime.exec("python myscript.py") seems blocked on waitfor(). code this:
process p = runtime.getruntime().exec("python myscript.py"); int exitcode = p.waitfor();
if try use same java code simple python script like
print "hello world"
i exitcode 0, means works. can execute python script imports wmi library, using java runtime.exec()?
thanks
one reason io buffers full , need flushed, try flushing both stdout , stderr process in java code (example code).
alternatively, try redirecting output nul or text file 1 of following arguments exec:
cmd.exe /c python myscript.py > nul 2>&1 cmd.exe /c python myscript.py > output.txt 2>&1
Comments
Post a Comment