CFExecute Output Not Going in Your Variable?
I’m blogging this because it’s a little tidbit I always waste about 30 minutes figuring out before I remember it.
The <cfexecute> tag can return the output of the execution into a variable if you supply one with the variable=”" attribute. However, I will try to do this, and (a) the script returns too quickly, and (b) there is no output when there should be.
There is an easy solution! <cfexecute> is expecting the timeout=”" attribute. Supply it a timeout value in seconds, and it will then wait for the script to finish executing and thus have output to store in your variable.
You may be wondering why this is necessary, because even without the timeout=”" attribute, the execution still occurs. <cfexecute> just doesn’t return any output. That’s because <cfexecute> is indeed running, it is just immediately timing out–effectively giving up on the executed process–and thus not returning the output. By supplying a timeout, ColdFusion hangs around waiting for the process to complete before returning its output.

February 13th, 2009 at 12:23 pm
Awesome tip! I definitely know people who have had to get CFX tags to handle CFExecute specifically because the output wasn’t being captured. I wonder if this would have been the better solution!
February 13th, 2009 at 1:58 pm
Don’t forget CF801 added errorVariable as a way to get the error output into a variable as well.
February 2nd, 2010 at 3:44 pm
This was driving me nuts, but the timeout value totally makes sense and fixed the problem…
Thanks!