Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
stiching python and batch
#1
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%
Reply
#2
Would var args work?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,184 Jun-29-2023, 11:57 AM
Last Post: gologica
  batch file for running python scipt in Windows shell MaartenRo 2 1,883 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  How to run script from batch file? jmair 1 4,256 Oct-12-2020, 04:29 PM
Last Post: jmair
  python script to Batch File biprabu 1 2,039 Sep-09-2020, 01:49 PM
Last Post: jefsummers
  changing code to work on a batch of images within a folder Afrodizzyjack 2 2,040 May-12-2020, 08:56 PM
Last Post: Afrodizzyjack
  Batch file not running python script in task scheduler davork 3 4,519 May-09-2019, 12:53 PM
Last Post: Gribouillis
  script for renaming batch of files rado_789 5 3,308 Nov-07-2018, 02:18 PM
Last Post: rado_789
  Python script batch download and batch rename jkhaksaar 3 3,421 Oct-11-2018, 03:42 PM
Last Post: snippsat
  Concept of batch files Truman 2 2,825 Jul-23-2018, 09:02 PM
Last Post: Truman
  Batch job from epoch to human time jheeman 6 4,493 Feb-27-2018, 10:53 PM
Last Post: jheeman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020