I tried os.popen and the like ways. But it does not seem to work for me. I'm wondering if there's anything different between a command 'echo xxxx' and 'java -version', and how can I get 'java -version' output with python code.
3 Answers
Yes, the difference is that java -version goes to the stderr stream. Try popen3 http://docs.python.org/library/popen2.html
3 Comments
Matthias
"Deprecated since version 2.6: This module is obsolete. Use the subprocess module."
CrazyCasta
So what, it's still commonly used. Lots of ppl use os.popen and I doubt it's going away in the 2.x branch (which is pretty much dead by now anyway).
Matthias
If something is deprecated I wouldn't recommend it.
subprocessmodule.