Search code examples
coldfusiondos

ColdFusion: Waiting for files to be created before acting on them


I have a series of files being generated with the following code:

<cfloop list="#clients#" index="idx">
    <cfexecute name="c:\windows\system32\cmd.exe" arguments='/c #APPLICATION.basepath#scripts\foldersize\dirP.bat #idx#'/>
    <cfexecute name="c:\windows\system32\cmd.exe" arguments='/c #APPLICATION.basepath#scripts\foldersize\dirA.bat #idx#'/>
</cfloop>

This fires off a number of requests to list those directories and pipe the findstr filter through to the respective files simultaneously...

What I need though is a way to ensure that the files are completely created before I use CFFILE on them to read in the output...

I'd use FileExists(), but it acts a little prematurely and I need it to be dead certain that the file is complete... Any ideas how to resolve this?


Solution

  • <cfexecute> has the timeout parameter. Just set it to a high number.

    It might be necessary to increase the overall request timeout.

    <cfsetting requesttimeout="300">