I'm executing a python file with powershell and I would like to get the log in a file and on console also, so tried to use the tee command.
cd folder
.\program.py | tee log.txt
But error was thrown back
Cannot run a document in the middle of a pipeline
Python file just contains 1 line of code
print "test"
How can I use this command at the right way?
You have to call python to execute the script. Try executing in the folder where program.py and log.txt is:
python program.py | tee log.txt
The explanation is that ./program.py without python command tries to run or open the file, but you are not executing it. Then, you try to to pass the ouput to log.txt with the pipe operator and tee. So it is the expected behaviour.
Aditionally, you are using python 2 syntax which is deprecated since ages. Try using print("test") inside the script.