CFX_execute


CFX_Execute is a replacement for the standard cfexecute tag. It was written to overcome the perceived poor performance of cfexecute under certain conditions, such as running programs on drives different to the ColdFusion install (WIN32). The tag should work with Linux/Unix systems as well though.

If you have any questions/comments/suggestions concerning this tag - please contact me via the email address here.


download

Execute.zip

The zip file can also be found on the Macromedia site here.

installation


There is no need to compile the tag unless you want to, just copy Execute.class to drive:path\CFusionMX\wwwroot\WEB-INF\classes\
Go to the ColdFusion administrator -> Extensions -> CFX Tags -> Register Java CFX
sEnter the following:

Tag Name: cfx_Execute
Class Name: Execute
Description: CFX Execute class
Then hit submit.  

documentation

<cfx_Execute
name="c:\windows\system32\ipconfig.exe"
arguments="/all"
outputvar="outfile1"
timeout="30"
lineend="<br />"
showdebug="yes"
outputfile="c:\myfile.txt"
reload="Auto">

Attributes : 
name (required) -The full path to the executable.
arguments (optional) -Command line arguments if required by the executable.
outputvar (optional) -ColdFusion scalar to hold the output of the executed.
timeout (optional) -A positive Integer - seconds (remove if the process is to run indefinitely).
lineend (optional) -Add a HTML tag ( <br /> for example) to pretty the output.
showdebug (optional) -Show the time taken to execute the command and attributes passed to the tag.
outputfile (optional) -Write the output of the command to the specified file.
reload (optional) -ColdFusion pragma to control the loading of custom classes: Please refer to the ColdFusion server documentation.
Compile : 
ColdFusion MX -drive:path\CFusionMX\wwwroot\WEB-INF\classes>javac -classpath drive:path\cfusionmx\lib\cfx.jar Execute.java
ColdFusion 4/5 -drive:path\CFUSION\Java\classes>javac -classpath drive:path\CFUSION\Java\classes\cfx.jar Execute.java

ColdFusion example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>CFX_Execute demonstration</title>
</head>
<body>
<cfx_Execute
name="c:\windows\system32\ipconfig.exe"
arguments="/all"
outputvar="outfile1"
timeout="30"
lineend="<br />"
showdebug="yes"
outputfile="c:\myfile.txt"
reload="Auto">

<cfoutput>
#outfile1#
</cfoutput>

<br /><br />

<cfx_Execute
name="d:\perl\bin\perl.exe"
arguments="-V"
outputvar="outfile2"
showdebug="yes"
lineend="<br>"
reload="Auto">

<cfoutput>
#outfile2#
</cfoutput>

<br /><br />

<cfx_Execute
name="c:\windows\system32\tracert.exe"
arguments="-d 10.10.10.15"
outputvar="outfile3"
timeout="30"
lineend="<br />"
showdebug="yes"
reload="Auto">

<br /><br />

<cfoutput>
#outfile3#
</cfoutput>
</body>
</html>

License & Disclaimer

License : Copyright (C) 2002 Simon Jones This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Disclaimer : THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.