I'm new in this, I want to write the output of java version in a file text.
I used this from another post I saw:
import subprocess
with open('C:\Python27\ping.txt','w') as out:
out.write(subprocess.check_output("ping www.google.com"))
And that worked, wrote the output of "ping www.google.com" to a text file.
I thought that if I just change the "ping www.google.com" to "java -version" everything would be solved.
Like this:
import subprocess
with open('C:\Python27\java.txt','w') as out:
out.write(subprocess.check_output("java -version"))
But this did not work me, this just print the output of "java -version" to console, and didn't write it in the text file.
Can anyone help me?