Jan-09-2025, 07:04 PM
Hi
I'm wondering if it's possible to get the stdout flux to a file and the consalole at the same time (i.e. in real time); i've made the (basic) example bellow using
Thanks for your help
Paul
Note: if the post name includes subprocess.run, iy is considered as a spam
I'm wondering if it's possible to get the stdout flux to a file and the consalole at the same time (i.e. in real time); i've made the (basic) example bellow using
ls -l
(but of course in my case, it's much more complex).Thanks for your help
Paul
Note: if the post name includes subprocess.run, iy is considered as a spam

import os, subprocess Path = os.getcwd() Outputfile = "output.txt" command_line = "ls -l" args = command_line.split() result = subprocess.run(args, stdout = open(Path + '/' + Outputfile, 'w')) print(result.stdout)