Posted by
dscho on
Oct 15, 2014; 7:48pm
URL: http://imagej.273.s1.nabble.com/Run-native-executable-in-a-plugin-Apache-commons-exec-or-processbuilder-tp5010068p5010070.html
Hi Dan,
On Wed, 15 Oct 2014, Daniel White wrote:
> Did anyone ever make a plugin or script or macro that runs a native
> executable as a sub process , perhaps using Apache commons exec or the
> native Java processbuilder?
Yep, sure I do. The org.scijava.util.ProcessUtils is designed to help you
with that:
http://jenkins.imagej.net/job/SciJava-common-javadoc/javadoc/org/scijava/util/ProcessUtils.htmlIt is basically a clean rewrite of the now obsolete fiji.SimpleExecuter
class:
http://jenkins.imagej.net/job/Fiji-javadoc/javadoc/fiji/SimpleExecuter.htmlBoth classes are available as part of Fiji. The main difference is that
the SimpleExecuter logs the output of the command to the Log window, while
the ProcessUtils return the output as a String. Here is a simple BeanShell
script demonstrating both (the /bin/echo command is available on Linux and
on MacOSX, on Windows you need to use something else):
fiji.SimpleExecuter.exec(new String[] {
"/bin/echo", "Hello, Dan!"
});
out = org.scijava.util.ProcessUtils.exec(null, null, null,
new String[] { "/bin/echo", "Hello, Dan!" }));
ij.IJ.log(out);
Ciao,
Dscho
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html