0

the below code checks the python version and calls the other python script to excute. I want to take all the logs of the below bat file, including the output of the python script into another log file. doing some test, I am able to put the logs into the file but the output still prints command print window. i thought it will redirect the output.

setlocal
SET "parent=%~dp0"
set LOGFILE=%parent%\run.log
call :LOG > %LOGFILE% 2>&1

:LOG
set "$py=0"
set "$ms=0"

call:construct
for /f "delims=" %%a in ('python dele.py ^| findstr "2"') do set "$py=2"
for /f "delims=" %%a in ('python dele.py ^| findstr "3"') do set "$py=3"

del %parent%\dele.py

if %%py%% == 0 echo "python is not installed" & goto :EOF

echo running with python %py%
for /f "delims=" %%V in ('pip -V') do @set ver=%%V
echo %ver%
pip install --user -r %parent%\requirements.txt
[output on command prompt][1]
echo connectivity script is running...
python %parent%\ConnChk.py
echo connectivity check is completed
goto :EOF
:construct
echo import sys; print('{0[0]}.{0[1]}'.format(sys.version_info^)^)>dele.py

I dont want to print anything on cmd. is there a way? any help would be great!!

[output on cmd][1] [1]: https://i.sstatic.net/qC4pZ.png

1 Answer 1

1

I got it worked.

using this link : https://superuser.com/questions/620865/dump-batch-script-output-into-a-text-file-without-specifing-batchfile-location-b

@echo off
REM setlocal enabledelayedexpansion

(
  content...
) > "%~dpn0.txt"

enclosing the code with open brackets got it worked!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.