I am trying to capture all the data that I get from a python script that I run into a variable. I took a few inputs from the user within the script and I want to capture everything from start till the end.
It is almost similar to this : Running shell command and capturing the output
But again this uses the subprocess within the script to get an output.
What I want is something like this:
when i run ls -l in the terminal, I want my script to capture the ouput of ls -l
If i write :
p2 = subprocess.Popen('ls' ,'-l',stdout= subprocess.PIPE).communicate()[0])
within my script, that will execute the script twice.
The expected output is to capture all the data when i run ls -l in the terminal to be captured in p2.