Nithin Dhruvah
Nithin Dhruvah

Reputation: 23

how to make python to wait until batch execution get complete

Path = location of batch file.(c:....\a.bat)

And a.bat contain following data: START C:\Python27\python.exe "C:.....\test.py"

I have the following code:

      my_process = subprocess.call(os.path.abspath(path), shell=True)

      text_file = open("output.txt",r)  # output.txt is batch file output

I expect the code should wait for batch file execution & output of batch file should generate output.txt. And later text_file = open("output.txt",r) should execute.

But code doesn't wait for batch file execution & sooner generate error that output.txt is not found.

Upvotes: 0

Views: 761

Answers (1)

Nithin Dhruvah
Nithin Dhruvah

Reputation: 23

Thanks @MarkSetchell, it works with

START /WAIT

Upvotes: 1

Related Questions