Windows Batch File-Wait Script
something i work with all the time, is a “file wait” need to kick off etl processes especially conditionally from an etl tool. i’ve always used a conditional file-wait method, and just wanted to share this with you.
here is a windows batch file script that will wait conditionally for a file to “appear”, and will exit based on two different conditions:
[code]
@set runtry=0
:start
@if exist %3 (
@exit(0)
)
@sleep %1
@set /a runtry+=1
@if %runtry% lss %2 goto :start
:errorout
@echo %runtry% exiting
exit(-1)
[/code]
the file should be called: check.bat
so: check 30 5 myfile.txt
will wait 30 seconds between “checking”, and will check for the file 5 times, then exit.
the exit(0) is success, and the exit(-1) is the failure condition.
i hope you find this helpful.
dan linstedt
Hi Dan,
Thanks a lot for your post. im trying to do the same, I create a check.bat file and can use this code. how do i call this in RED via scheduler or host scripts.
Can you throw some light on how it is done via host scripts. i mean calling the .bat file . pleae
Hi Satish,
Not sure I understand your question. If you are referring to executing the BAT file from Wherescape RED, then I’m afraid I don’t have the answer. I’m not yet trained on RED – that should happen soon though. In the mean time a quick question to the Wherescape team from you, should do the trick, They should give you the answer right away.
Hope this helps,
Dan L