Pipa's
Pipa's

Reputation: 61

Import variable from Python script to Batch file

I have a python script containing vraibles example.py

"src = komponent/cool,
       komponent/raw"  /* path of source files */

and i have a batch file which needs to import the value of "src" for postporcessing example.bat

--cs-include ='komponent/cool'* --cs-include ='komponent/raw'*

Is there any way to import directly between files (without using any other conversion) ? "PyBat.bat" is one option but i am trying to figure out a better choice dont want to add on one more tool (not specifically)...as my project itself has too different files and interacting source.

Any help is appreciated.. Thank you in advance..!!!

Upvotes: 0

Views: 1583

Answers (2)

Pipa's
Pipa's

Reputation: 61

Solution is... 1.set a argument in the python itself. 2.call the batch file from python script and along with pass the argument using os.system(cmd) and cmd as a string.

It will set the path itself.

Upvotes: 0

AjV Jsy
AjV Jsy

Reputation: 6075

In Python
Create a temp batch file in %TEMP%\setvars.bat containing SET commands to set environment vars. You could use subprocess.POpen to run an ECHO something > path batch command so that %TEMP% can be used.

In Batch
Call the temp batch file : the vars are now available to use.

Upvotes: 1

Related Questions