coldfusionexecoldfusion-10cfexecute

Returning all output using CFEXECUTE


I have a CFEXECUTE tag somewhat like the following:

<cfexecute timeout="10" 
variable="result" 
name="#PathToExecutable" 
arguments="#myArgs#">
</cfexecute>

The problem I am having is that not all output is being captured by the tag. When I run the executable directly from the command line it prints out several lines of text one after the other but not all at the same time. I need to inspect the text output in the last line.

But when I run the executable using CFEXECUTE it seems to capture the first line of output, assume the process has finished and then return to running my CF script.

Has anybody else encountered this and if so is there any possible solution?

More info:

The image below shows the output produced when the executable is run from the command line. The yellow section is all that is returned by CF. The information I need is the green section. The script containing the CFEXECUTE tag seems to run very quickly and the full timeout value is definitely not being reached before the output is returned.

CMD screen grab


Solution

  • After running lots of tests I have found the answer.

    If the path to the file to be scanned contains spaces it must be in double quotes within the arguments parameter of the cfexecute tag e.g.

    <cfexecute timeout="10" variable="result" name="#pathToExe#" arguments='"#pathToScan#"'></cfexecute>
    

    If the file path is incorrect/does not exist this particular executable seems not to return any useful error text but just return the yellow highlighted line in the above image.