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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -