I made this simple .bat
batch-file containing
@echo off
set log=mainLog.txt
cd /d F:/Project/Python
echo [%TIME%]starting main.py >%log%
python main.py >> %log%
the command prompt is successfully redirect main.py
output to the log file, but doesn't show it on prompt screen. So I change it to:
python main.py 2>> %log%
this will show the output of main.py
to the prompt screen but not redirecting to log file. I've already tried to use:
python main.py 2>> %log% 1>> %log%
but this give me:
The Process cannot access the file because it is being used by another process
Let's assume that my main.py
containing:
for i in range(10):
print("this is line no. {}".format(i))
Is there any idea how this could be done?