I'm trying to redirect an output from a shell window opened from a python script - to a file.
So, after some googling, I came up with this code:
file_output = open(MS_Log + 'LOGS.txt', 'w+')
subprocess.call('start ' + URL_logs, shell=True, stdout=file_output)
This does indeed opens a new shell window and runs the command I want in it. However, the output is printed on the screen (inside that new shell window) and not to the file.
I want it to be both - printed in the shell window and saved to file.
Now, the command I run there is continuous, it runs until stopped with Ctrl+C, so I think this might be the problem...? Maybe if it will be closed gracefully it will dump it's contents to the file?