I have a shell script which I want to execute within a Java class. The shell script takes an input file and produces an output file from it.
To execute it, I use apache commons exec. Here's my little code:
CommandLine cmdLine = CommandLine.parse("/bin/sh ./generate_void_description.sh ./n3file ./voidfile");
int exitValue = executor.execute(cmdLine);
As a Result i get this Error Message :
./generate_void_description.sh: 44: ./generate_void_description.sh: Syntax error: "(" unexpected
org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2)
Of course I can read and I understand that the message means that there's a syntax Error in the script but.
1) I didnt write the script and I'm not familiar with bash script syntax 2) The script works perfectly without any errors when I run it on a terminal within ubuntu
Has it something to do with User rights ? I need to create an output file maybe I don't have the permissions to do this if if
The script uses bash features, most noticeably an array in line 44. You'll have to execute the script using /bin/bash
, not /bin/sh
.