I wonder is there a way to instantiate a shell and keep it resident in memory across cfexecute commands, or through some other as yet unbuilt feature? Could be very useful in a case like Ivan’s where multiple commands need to be run. I know I have written code that used multiple shell commands in a single method, and it would seem like a good thing for commands that are going to be executed in sequence within the same context/thread be able to share the same instance of the shell.
FYI, I know in Ivan’s case he was able to solve his issue by putting all the commands in a single sh file, but there would invariably be cases where that solution doesn’t work because other things are going on inside the code in between individual shell calls.
Is this issue resonating with anyone else? I have been pining for a better method of CLI integration than what cfexecute has always offered. Looking at the Java.lang.Runtime class, it doesn’t look like there is a way to persist a process within the context of an exec() method call, but maybe some of the more expert Java coders know something I don’t about it.
I know you can do something like this:
process_runtime = local.runtime.getRuntime();
process_exec = local.process_runtime.exec( javacast( "string[]", ["bash", "-c", str ]) );
exitCode = local.process_exec.waitFor();
process_exec2 = local.process_runtime.exec( javacast( "string[]", ["bash", "-c", str2 ]) );
exitCode = local.process_exec.waitFor();
but you are still instantiating a new bash shell with each .exec() method call.
I realize leaving it open could be playing with fire and maybe that’s why java.lang.Runtime calls each exec() in a separate process. It just seems like there should be a better way to integrate with the shell than what currently exists.
Robert> On Mar 3, 2016, at 1:08 AM, Ivan <@Ivan> wrote:
I confirm. It would seem that so many cfexecute one after the other is not good. I grouped all in a bash file.
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/14ab8bd9-9502-458d-9dec-41c884eb00f8%40googlegroups.com https://groups.google.com/d/msgid/lucee/14ab8bd9-9502-458d-9dec-41c884eb00f8%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.