subprocess capture sdtout code example
Example 1: python get output
>out = subprocess.Popen(['wc', '-l', 'my_text_file.txt'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
Example 2: python write subprocess stdout stderr to file
with open("stdout.txt","wb") as out, open("stderr.txt","wb") as err:
subprocess.Popen("ls",stdout=out,stderr=err)