A Couple Of <CFEXECUTE> Gotchas

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

  • There is no way to tell 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 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

5 responses to “A Couple Of <CFEXECUTE> Gotchas”

  1. Big Kev Avatar
    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.

  2. Sam Curren Avatar
    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.

  3. Bob Clingan Avatar
    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…

  4. Barry Avatar

    The redirection that you mentioned should also work for Unix.

  5. Tim Blair Avatar
    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:

Leave a Reply