batch file - wait statement in python -
i have python code looks this:
os.system("...../abc.bat") open("test.txt") .....
where abc.bat upon complete run creates test.txt. problem since there no "wait" here code directly goes open("file.txt") , naturally not find , hence problem.
is there way can find out status if bat run has finished , python can move open("test.txt")?
note: have used idea in bat file has command- type nul>run.ind , file deleted bat file @ end indicator bat run has finished. can somehow make use of in python code :
os.system("...../abc.bat") if file run.ind exists == false: open ("test.txt")
this seems crude. there other methods in simpler way? or in other words possible introduce "wait" till bat run finished?
maybe try put on while loop.
import os import time os.system("...../abc.bat") while true: try: o = open("test.txt", "r") break except: print "waiting bat.." time.sleep(15) # modify (seconds) se sufficient bat ready continue
Comments
Post a Comment