I have a perl script that needs 2 arguments to be run. I am currently using Ubuntu and I managed to execute the perl script from terminal by changing directory to where the perl script exists and by writing
perl tool.pl config=../mydefault.config file=../Test
However, when I am trying to run the perl script from my java program (I am using eclipse), It always gives me the message Command Failure. This is the code :
Process process;
try {
process = Runtime.getRuntime().exec("perl /home/Leen/Desktop/Tools/bin/tool.pl config=../mydefault.config file=../Test");
process.waitFor();
if(process.exitValue() == 0) {
System.out.println("Command Successful");
} else {
System.out.println("Command Failure");
}
} catch(Exception e) {
System.out.println("Exception: "+ e.toString());
}
So please what is wrong in my code?
$?. Are you sure you're running it from the right directory in the Java code?