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.

  Theme Brought to you by Directory Journal and Elegant Directory.