O'Reilly logo

Programming ColdFusion MX, 2nd Edition by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing Command-Line Programs

You can use the cfexecute tag to execute command-line programs residing on the same machine as the ColdFusion Application Server. This tag allows you to call external programs, such as batch utilities, from within your ColdFusion application. The following syntax calls an external program using cfexecute:

<cfexecute name="path_to_program_to_execute" 
           arguments="argument_string"
           variable="variable_name"
           outputfile="path_to_output_file"
           timeout="timeout_in_seconds">
</cfexecute>

The name attribute is required and specifies the full path, including filename, to the file you want to execute. Depending on the program you are attempting to execute, you may be able to specify just the program name without the full path. arguments allows you to specify any optional arguments you want to pass to the external program. arguments can be either a string or an array and adheres to the following conventions:

String

On Windows platforms, the entire string is passed to the Windows process control subsystem for processing.

On Unix and Linux systems, the string is tokenized into an array of strings, delimited by spaces. If spaces occur in the array elements, they are escaped by double quotes.

Array

On Windows platforms, the elements of the array are concatenated into a space-delimited string of tokens, which is then passed to the Windows process control subsystem for processing.

On Unix and Linux systems, the elements of the array are copied into an array of exec( ) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required