Client Login
Email:
Password:

cfexecute weirdness

I ran across an interesting "quirk" using CFexecute today...

When I run this code:

<cfexecute name="c:\windows\system32\tree.com" arguments="/?" variable="bar" />

<cfdump var="#bar#" />

...I get the error that "variable 'bar' is undefined".

...however if I use the "outputfile" attribute instead of "variable", I do indeed get the results I want.

After some discussion on the BACFUG list, it seems that the "timeout" attribute is required:

<cfexecute name="c:\windows\system32\tree.com" arguments="/?" timeout="20" variable="bar" />

...but if I don't include it, CF will happily compile and run the code, even if it's not able to populate my variable properly. :)

Comments
Sean Corfield's Gravatar The documentation is pretty clear about this!

Quote:

timeout

Optional

0

Length of time, in seconds, that ColdFusion waits for output from the spawned program.

0: equivalent to nonblocking mode.
A very high value: equivalent to blocking mode.
If the value is 0:

ColdFusion starts a process and returns immediately. ColdFusion may return control to the calling page before any program output displays. To ensure that program output displays, set the value to 2 or higher.
If the outputFile attribute is not specified, any program output is discarded
# Posted By Sean Corfield | 2/8/08 12:43 AM
Nolan Erck's Gravatar Yes I see that note under the "timeout" attribute now. When I was reading the docs before, I think I had mentally lumped "timeout" in with something else (perhaps use of "outputfile", figuring writing to a file on disk would take extra time and thus might need a "timeout" attribute as well), so I skipped it when trying to get "variable" working.

Thanks for the clarification.
# Posted By Nolan Erck | 2/8/08 9:57 AM
Jake Munson's Gravatar Yup, I've run into this before as well. Thanks for the reminder.
# Posted By Jake Munson | 2/8/08 11:21 AM
 
BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. Contact Blog Owner