CFLib.org – Common Function Library Project

Execute(name[, args][, timeout][, outputFile])

Last updated October 16, 2002

author

Raymond Camden

Version: 1 | Requires: CF6 | Library: CFMLLib

Description:
Mimics the cfexecute tag.

Return Values:
Returns a string.

Example:

<cfscript>
//x = execute("c:\winnt\system32\netstat.exe","-e",20);
//writeOutput("x is #htmlCodeFormat(x)#");
</cfscript>

Parameters:

Name Description Required
name Program to execute. Yes
args Args to pass. Can be string or array. No
timeout Time to wait for program execution. No
outputFile File to save results. No

Full UDF Source:

<!---
 Mimics the cfexecute tag.
 Updated for CFMX var scope.
 
 @param name      Program to execute. (Required)
 @param args      Args to pass. Can be string or array. (Optional)
 @param timeout      Time to wait for program execution. (Optional)
 @param outputFile      File to save results. (Optional)
 @return Returns a string. 
 @author Raymond Camden (ray@camdenfamily.com) 
 @version 1, October 16, 2002 
--->
<cffunction name="execute" output="false" returnType="string">
    <cfargument name="name" type="string" required="true">
    <cfargument name="args" type="any" required="false" default="">
    <cfargument name="timeout" type="string" required="false" default="0">
    <cfargument name="outputfile" type="string" required="false" default="">

    <cfset var result = "">
    
    <cfsavecontent variable="result">
        <cfif len(outputFile)>
            <cfexecute name="#name#" arguments="#args#" timeout="#timeout#" outputfile="#outputfile#"/>
        <cfelse>
            <cfexecute name="#name#" arguments="#args#" timeout="#timeout#"/>
        </cfif>
    </cfsavecontent>
    <cfreturn result>
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson