3

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

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Michael
  • 1,643
  • 1
  • 15
  • 31
  • 1
    The question is not clear. Does the result variable give you anything resembling desired results? – Dan Bracuk Apr 28 '14 at 16:10
  • Could be the timeout. If your script is slow, 10 seconds may not be enough time to 'capture' all the output. – Raymond Camden Apr 28 '14 at 18:56
  • When I run the script manually from the command line it runs in a second or so, so ten seconds should be more than enough. The result variable contains the first line of the output but that line does not contain the information I need. I'm not sure how to explain it any better. When run from the command line the output is printed in several steps as the operation proceeds. The final output print contains the useful information I need but ColdFusion seems to only capture the output from the print which is not useful to me. – Michael Apr 28 '14 at 21:27
  • What does this executable do? – Dan Bracuk Apr 29 '14 at 01:16
  • It performs a virus scan on a specified file – Michael Apr 29 '14 at 08:07
  • I have updated the question with a screen grab of the output when run from the command line – Michael Apr 29 '14 at 10:24
  • 1
    Is it behaving this way in a self contained test? Meaning, create a cfm template that has the bare minimum code in it for the cfexecute code to run. Does it behave the same way? – Miguel-F Apr 29 '14 at 11:12
  • When I run the self-contained test all of the output is returned as desired – Michael Apr 29 '14 at 11:18
  • The problem seems to be occurring when the virus scan UDF is called from within another UDF. If I call the virus scan UDF directly then the full output is returned. – Michael Apr 29 '14 at 11:33
  • 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. ``. If the file path is incorrect/does not exist this particular executable seems not to throw an error but just return the yellow highlighted line in the above image. – Michael Apr 29 '14 at 12:22
  • Great! Glad you found the culprit. Go ahead and post that as an answer to your own question. It is okay to do that here and it will be easier for future readers to find. – Miguel-F Apr 29 '14 at 12:25

1 Answers1

1

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.

Michael
  • 1,643
  • 1
  • 15
  • 31