I am trying to create a java program that takes some user-input variables and passes them to a perl script (it actually finds a certain string within the perl script and replaces it with the user-input variables). Here is the code:
String sedMain = "sed -e ";
String sedFirstLine = "'s/AAA/"+newFirstLine+"/' -e ";
String sedNewCntr = "'s/BBB/"+newCntr+"/' -e ";
String sedNewSpacing = "'s/SPACE/"+newSpacing+"/' -e ";
String sedNewDmax = "'s/MAX/"+newDmax+"/'";
String sedFile = " /filepath/myperlscript.pl > /filepath/myNEWperlscript.pl";
String sedCommand=sedMain+sedFirstLine+sedNewCntr+sedNewSpacing+sedNewDmax+sedFile;
System.out.println("SED COMMAND: "+sedCommand);
String testRun = "touch /filepath/hello.txt";
Process runSedCommand;
runSedCommand = Runtime.getRuntime().exec(sedCommand);
I am using an IDE, and when the sed command is printed to the console, it looks correct. I copied the sed command from the console and ran it from the terminal, and it worked. I wrote the string "testRun" to see if there was a problem with the Process in Java, and it created the file "hello.txt". For some reason though, my program is not creating the output perl file "myNEWperlscript.pl". I am very confused as to why this is not working. Can anyone help out?