Java альтернатива cfexecute
Сергій Галашин - 11/27/2009
Марк Дрю розповів про зручну заміну cfexecute. Залишимо його приклад для коміту в репозиторій Git в якості пам'ятки для розробників без Java-досвіду:
<!--- since we have made modifications to the files, we need to commit them in git --->
<cfscript>
// first of we set the command to call
cmd1 = "git add TODO.txt";
cmd2 = "git commit -m 'autobackup'";
// the environment variable is empty
envp = arraynew(1);
// and we want to run from a given "root"
path = "/Volumes/iDisk/Documents/TODO";
dir = createobject("java", "java.io.File").init(path);
// get the java runtime object
rt = createobject("java", "java.lang.Runtime").getRuntime();
// and make the exec call to run the command
rt.exec(cmd1, envp, dir);
rt.exec(cmd2, envp, dir);
</cfscript>