I have this script below (called compute.sh and used to start ROOT application(CERN)(root.exe) and execute some c++ macros with it)
#!/bin/bash
ROOTSH=/path/to/files root -b -l macro.cpp
$ROOTSH &
ROOT_PID=$!
echo $ROOT_PID > .lock
In order to launch this .sh from my java deployed application on the same Linux server I use:
try{
Process p = Runtime.getRuntime().exec("/path/to/files/compute.sh");
p.waitFor();
}catch( IOException ex ){
log.warn("Cannot find bat or sh to start ROOT");
}catch( InterruptedException ex ){
log.warn("The ROOT execution is interrupted");
}
But when I try to start this .sh from th UI, I have nothing, no results and no errors. And when i run the .sh from outside the java code, it works perfectly.
Does anyone have an idea how to handle this please? Or Is there another way to make sure the shell script will be run from the java code?