python get output of command to variable
import subprocess as sp output = sp.getoutput('whoami --version') print (output)
Source: stackoverflow.com
python os get output
os.popen('cat /etc/services').read()
Source: stackoverflow.com
python get output
>out = subprocess.Popen(['wc', '-l', 'my_text_file.txt'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Source: cmdlinetips.com