I am using subprocess.run to run a command and print output to a file.
I am able to print correct output for 'python --version' since the answer is 'Python 3.6.5', but when i run the same command for 'java -version' there is no output in text file, but it is reflected in console.
Maybe it's because the output of 'java -version' is spread in three lines!
import subprocess
import os
import sys
sys.stdout = open('outputCS.txt','wt')
result = subprocess.run('python --version', stdout=subprocess.PIPE)
print(result.stdout.decode('utf-8'))