Blog

11Sep
2006
A Couple Of <CFEXECUTE> Gotchas

Two little gotchas and tips pertaining to <cfexecute> that you should be aware of:

  • There is no way to tell <cfexecute> where to execute your command. If you need to be in a specific folder when the command is executed, you should execute a batch file or script, and have it change to the desired folder and then execute the command.
  • The <cfexecute> tag captures output (which can be returned, or saved to a variable or file). But only stdout output is captured, not stderr, and so if the command you are executing generates error messages to stderr you'll not see those in the captured output. The solution is to redirect stderr to stdout, if you are using Windows you can do this by adding the following to the end of the command to be executed: 2>&1

Related Blog Entries

Comments (5)



  • Big Kev

    I've always found that CFEXECUTE not to be as useful as CFX_CONSOLECOMMAND which I have modified to allow the choise of 2>&1 as an output as that can be very useful.

    #1Posted by Big Kev | Sep 11, 2006, 09:03 AM
  • Sam Curren

    One more: It's in the documentation, but this threw me for a loop. The CFExecute Tag is Async by default. This is nice for spawning lots of processes when you need a silent job done, but can be a pain if you end up running processes that need to be run one instance at a time.

  • Bob Clingan

    Another issue I've noticed is make sure which "user" you are running as. I was setting up GnuPGP on a Windows system and it took some debugging time to figure out where the keychain was stored...

    #3Posted by Bob Clingan | Sep 11, 2006, 10:42 AM
  • Barry

    The redirection that you mentioned should also work for Unix.

    #4Posted by Barry | Sep 13, 2006, 02:23 PM
  • Tim Blair

    There's a Java-based work-around which allows you to 'position' where a <cfexecute> (equivalent) call is run from. You can use the exec() method from java.lang.Runtime, as I outlined in the following post from a little while back:

    http://tech.badpen.com/index.cfm?mode=entry&en...

    #5Posted by Tim Blair | Sep 25, 2006, 10:36 AM