0

Now I am able to pass the whole list from batch file to python but I want to pass the each element in each looping. How can I achieve this?

sub.py

import subprocess
import random

item = subprocess.Popen(["test.bat", str(random.randrange(0,20))] , 
                         shell=True, stdout=subprocess.PIPE)
for line in item.stdout:
    print line

test.bat

set list=hai hello trial 
(for %%a in (%list%) do ( 
   echo %%a 
))
Prajna Hegde
  • 670
  • 4
  • 11
  • 31
  • possible duplicate of [this](https://stackoverflow.com/questions/10823033/sending-arguments-from-batch-file-to-python-script) – Manmohan_singh Jan 24 '18 at 04:35
  • 2
    Possible duplicate of [Sending arguments from Batch file to Python script](https://stackoverflow.com/questions/10823033/sending-arguments-from-batch-file-to-python-script) – Manmohan_singh Jan 24 '18 at 04:36

0 Answers0