I have a java code that takes a data file, copies the data to a perl script, and calls the perl script from a shell script. Here is the relevant code:
public String returnStringForPerlScript(ArrayList<String> arrayContainingPerlScriptArguments, String singularFilePath) throws IOException{
String argFileName = null;//5
String argParsedFileName = null;//
argParsedFileName = arrayContainingPerlScriptArguments.get(4);
argFileName = arrayContainingPerlScriptArguments.get(5);
System.out.print("ARG1: "+argFileName);
System.out.print(" ARG2: "+argParsedFileName);
String runCmdString = singularFilePath+"perlscript.pl";
String runCmd = singularFilePath+"runPerlScript.sh";
return runCmd;
}
The code above is a method in a separate class. The code below is where the Process is actually initialized and ran.
p = dfp.returnStringForPerlScript(perlParam, singularDirectoryPath);
System.out.println("Running from: "+p);
process = Runtime.getRuntime().exec(p);
What is confusing is that this code worked perfectly well earlier, and all I changed is the output directory. Instead of "singularDirectoryPath", I had written out a completely different file path. I am very confused because I have no idea what is wrong with the code, considering it ran before. When I called "runPerlScript.sh" from the terminal, it worked.
I also should add that I did try to use a String[] instead of a string, as shown below:
String[] cmdArray = {"/bin/tcsh","-c","/filepath/runPerlScript.sh"};
Process p = Runtime.getRuntime().exec(cmdArray);
Still did not generate any output files.
exec()has nothing to do with.