Dec-20-2024, 06:27 AM
How to run shell command, capture the output, then write it into textfile?
I tried to use code below:
there is error message: 'str' object is not callable
How can I capture / assign the stdout result into a variable as string?
Can I do something like:
Result = data.stdout()?
Thank You
I tried to use code below:
from subprocess import run
data = run("cstool arm64 1F2003D5", capture_output=True, shell=True, text=True)
print(data.stdout)
hfile3 = open("result1.txt", "a")
hfile3.write(data.stdout())
hfile3.close()It can successfully print what I want, but it cannot write into text filethere is error message: 'str' object is not callable
How can I capture / assign the stdout result into a variable as string?
Can I do something like:
Result = data.stdout()?
Thank You
