ColdFusion 8.0.1 change to CFEXECUTE

This post is more than 2 years old.

I haven't seen this discussed yet, so I thought I'd bring it up (for those of you too lazy to read the release notes, and you know who you are!). One of the cool changes to ColdFusion 8.0.1 is the addition of the errorVariable and errorFile attributes to the cfexecute tag. As you can guess, this helps record any errors that may return from your external process. Before this change, there was no way to get the error. Here is a simple example:

<cfexecute name="#variables.bin#" arguments="#realcommand#" variable="result" timeout="99" errorVariable="errorv"/>

<cfif len(errorv)> Handle the error... <cfelse> Handle the good result... </cfif>

Pretty simple, right? One thing to watch out for is that you cannot use both errorVariable and errorFile. So if you want programatic access to the error and you want to log it - simply use errorVariable and then follow it up with a fileWrite() to save the string.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Joshua Curtiss posted on 4/9/2008 at 5:46 PM

SWEET! That's always been an irritation, and I managed to find workarounds, but that will be very handy.

Comment 2 by John Allen posted on 4/9/2008 at 7:08 PM

SWEET and SHARP! Missed that one.

Comment 3 by Eric posted on 4/24/2008 at 12:14 AM

Don't miss my discussion from <i>before</i> 8.0.1 (=D) about a cfexecute alternative which flushes to the browser in real time and also gives you access to stdout and stderr. Without much additional effort you could write to stdin (there's a stub for it in this code) to interact with a program.

This should also work for people stuck on CF 6, 7, or 8.0.0.

Comment 4 by Mike Lerley posted on 9/18/2009 at 12:31 AM

Thank you! Just saved me hours.

Comment 5 by Raymond Camden posted on 10/29/2013 at 11:38 PM

As just an FYI, apparently this wasn't ever documented. I just fixed it in the wiki.