<cfexecute> lets you execute any process on the server machine. The process is effectively invoked from the command line, spawning a separate thread. This powerful tag provides your ColdFusion code with access to a wealth of system applications, from Perl and shell scripts to Windows executables and batch files. You can pass <cfexecute> a series of command-line ARGUMENTS as either a string or an array: <cfexecute name="c:\perl\bin\perl.exe" arguments='-e print "hello world!";' timeout="20"> </cfexecute> NOTE In Perl, -e allows a line of code to be executed from the command line. NOTE On Windows systems, you must specify the extensionfor example, .exeas part of the application's name. The application's full pathname is also required. The output of the external program is directed to the specified outputfile, as shown in the following example. Alternatively, if no file is nominated, the output is written back to the page from which it was called. <cfscript> aArgs=ArrayNew(1); aArgs[1]="/all"; </cfscript> <cfexecute name="C:\WinNT\System32\ipconfig.exe" arguments="#aArgs[1]#" outputfile="c:\x\ipsettings.txt" timeout="500"> The timeout indicates how long in seconds the ColdFusion executing thread will wait for the spawned process to finish. Using the default timeout of 0 forces the ColdFusion thread to spawn a process and immediately return without waiting for the process to terminate. The file is effectively executed asynchronously from the ongoing processing of the calling application page. NOTE The effective user of the ColdFusion executing thread must have permissions to execute the program on the server. If not, a security exception is thrown. |