Browse Source

Another idea

master
Julio Biason 2 years ago
parent
commit
956d916002
  1. 7
      tee.py

7
tee.py

@ -31,6 +31,13 @@ def main():
with Tee('tee.txt', 'w') as target:
subprocess.run('ls', stdout=target, check=False)
with open('tee2.txt', 'w') as output:
with subprocess.Popen('ls', stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
for line in proc.stdout:
print(f'--> {line.decode("utf-8")}', file=output)
result = subprocess.CompletedProcess(proc.args, proc.returncode, proc.stdout, proc.stderr)
print(result)
if __name__ == '__main__':
main()

Loading…
Cancel
Save