I have a python code which looks something like this:
os.system("...../abc.bat")
open("test.txt")
.....
Where the abc.bat upon complete run creates test.txt. Now the problem is that since there is no "wait" here code directly goes to open("file.txt") and naturally does not find it and hence the problem.
Is there any way I can find out status if the bat run has finished and now the python can move to open("test.txt")?
Note: I have used an idea where in the bat file has command- type nul>run.ind and this file is deleted by the bat file at the end as an indicator that bat run has finished. Can I somehow make use of this in the python code like :
os.system("...../abc.bat")
if file run.ind exists == false:
open ("test.txt")
This seems to be somewhat crude. Are there any other methods to do this in simpler way? or in other words is it possible to introduce some "wait" till the bat run is finished?
os.system()
would wait for execution to finish. Can you tell us whatabc.bat
is doing? Is it launching something that runs asynchronously?