Reputation: 119
I am trying to automate a task on a file using Python pwntools.
However, no matter what I do I am unable to get the output.
Based on the behavior of the program (for example: that it takes up the entire terminal window, among other things) I believe that it is displayed using the dialog
command.
I have tried many things, but nothing seems to capture the data.
Even if I try script output.txt
and run either the file or, for example, dialog --yesno "\nBla bla bla...\n\nDo you accept?" 10 30
the output just isn't captured.
I would also like to capture the data while the program is running, I do not want to close it.
Thanks!
Upvotes: 1
Views: 319
Reputation: 71
import sys
sys.stdout=open("test.txt","w")
print ("hello")
sys.stdout.close()
Now the hello will be written to the test.txt file. Make sure to close the stdout with a close, without it the content will not be save in the file
Upvotes: 1