0

I am running a python script that dumps out some text and results and i want to see the result of the execution on the CLI when running the script also I want to keep these result inside a file such as a text file. I have noticed that by redirecting the flow using '>' prevent you from seeing the execution on the CLI is there any other solution.

  • You can check this link : https://stackoverflow.com/questions/14906764/how-to-redirect-stdout-to-both-file-and-console-with-scripting – Ranga Feb 17 '20 at 15:34
  • usually people use [logging](https://docs.python.org/3/library/logging.html) to save some data in file. On Linux you could use `tee` instead of `>` to split stdout and save in file and also display it - and it doesn't need changes in Python code. `python script.py | tee 'output.txt'` but I don't know if it works when script ask user for data. – furas Feb 17 '20 at 15:41
  • @furas i am using windows – Ahmed Ben Soltane Feb 17 '20 at 15:47
  • you can install some Linux programs on Windows - see [gnuwin32](http://gnuwin32.sourceforge.net/packages/coreutils.htm). OR write similar program using Python. – furas Feb 17 '20 at 16:16

0 Answers0