Python Forum
stiching python and batch - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: stiching python and batch (/thread-17217.html)



stiching python and batch - jenya56 - Apr-02-2019

Dear all,
I have found the way to communicate between python and batch file. Below is my python and batch file. As you can see it is not that pretty as I am passing variables one at the time(variable[0],variable[1]).
However, the solution below will become unsustainable once "variables" vector becomes larger.
Any suggestions?
variables = ['2000','3000','4000']

item = subprocess.Popen(['batch_multiple_variables.bat', variables[0],variables[1],variables[2]] , 
                         shell=False, stdout=subprocess.PIPE)
My batch code:
@echo off
set arg1=%1
set arg2=%2
set arg3=%3

set /a vari1=%arg1%
set /a vari2=%arg2%
set /a vari3=%arg3%


RE: stiching python and batch - micseydel - Apr-02-2019

Would var args work?