I have two Python scripts. The first, when run on a text file, outputs ten lines of text to the console (I cannot paste the code here, unfortunately).
The second Python script successfully runs the first, and runs the script in a loop numerous times - again, outputing to the console.
I cannot, however, work out how to capture this output into a variable in my second script (so I can save it to a file). Attempting to capture this output into a variable (just to try printing) just gives many lines of error. (I'm sure this is a newbie error).
import sh
import 1st-script
n = 10
for i in range(n):
list = exec(open("1st-script.py").read())
print(list)
I understand that this is something to do with the exec() not making its output available for inclusion in the variable. So any thoughts would be great.