Login  Register

Re: runtime fails when command has arguments

Posted by jvander on Dec 11, 2014; 8:27pm
URL: http://imagej.273.s1.nabble.com/runtime-fails-when-command-has-arguments-tp5010889p5010918.html

Thanks again Michael.  It turned out that my actual problem was a different one.  I had not specified the path for the sciscript.   Once I did this the original method worked:

Process p = Runtime.getRuntime().exec("/commandpath/scilab-cli -f /scriptpath/sciscript");

So having the -f with white space followed by the script did not actually cause my problem.  Before I figured the path problem out, I did study the documentation pages on Runtime that you provided and I did indeed like the command array approach.  I ended up modifying your proposal as follows:

String cmdarray[]={"/commandpath/scilab-cli",  "-f",   "/scriptpath/sciscript"};
Process p = Runtime.getRuntime().exec(cmdarray);

This is a more modular approach so thank you very much for your help.  

On a more general note, the marriage of ImageJ and the command line interpreter for scilab is a huge boon for me.  I have used ImageJ for visual manipulation and to perform a wide range of standard postprocessing for years, but my lack of skills in java programming has prevented me from writing more serious code.  Through the use of runtime I can use the power and simple command environment of a program like scilab or matlab  to implement sophisticated algorithms (in my case iterative Fourier transform processes).   ImageJ then serves as a sort of "super GUI" that calls the scilab program but also manipulates the output.  This is a big step forward for me.   ImageJ is a fantastic resource and Wayne and the community are great in helping folk like me with limited programming experience.  I am thankful indeed.

Of course this hybrid approach is not the ideal, but given my limited time to spend learning java this is a great solution for me.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html