I have a bat file from where I am calling a python script. I need to pass a variable value from the python script to the bat file. The python script is present in another folder and is not in the same level/scope as that of the bat file. My folder structure is as follows:
Folder_Structure
- demo/test_val.py
- build.bat
I am doing the following but it does not work
test_val.py:
import os
name="Redwood"
os.putenv("NAME",name)
build.bat:
@echo off
python demo/test_val.py
echo %NAME%
I am unable to figure out how to achieve this. I don't want to call the bat from my python script instead it should be the other way round i.e. bat should call the python script. Please help, any alternate solutions to get the var name from my python script to my bat file is also welcome. Thanks.