[Biojava-l] gromacs shell script

Thomas Down td2 at sanger.ac.uk
Thu Dec 8 09:46:08 EST 2005


On 8 Dec 2005, at 14:16, Tamas Horvath wrote:

> I know this is not strictly BioJava, but here's my problem:
> I create a shell script file that would run a GROMACS MD  
> simulationI generate the necessary input and config files
> I can make the generated shell script runnable
> I cannot actually run the script from the Java application.
> The script works fine from shell...
> The returned exitValue is 255.
> Can anyone tell, what may I do?

Could you give a few more details about the code you're using to run  
the shell script from Java?  Running external processes using Java's  
Runtime.exec method isn't totally trivial -- you usually need to  
start some extra threads to handle the child process' input and output.

I presume your script is actually printing some kind of error message  
to standard error (or maybe standard out, if it's badly behaved, but  
these may be getting lost.

BioJava has some convenience methods that (usually) allow you to run  
child processes without writing your own multithreaded code.  A  
simple usage, that echoes the child's errors and outputs to the  
console, would be something like:

          ProcessTools.exec(
                           new String[] {"/path/to/my/script", "- 
someArgument"},
                           null,           // no standard input
                           new OutputStreamWriter(System.out),
                           new OutputStreamWriter(System.err)
          );

You probably don't want to do this in production code, but for  
development and debugging it's quite useful.  For production use,  
you'd normally use StringWriters to capture the child process' output.

             Thomas.


More information about the Biojava-l mailing list