I am using process builder to execute multiple shell commands (not external shell script) from Java. I can pass system environment variables to the shell command; However, if I want to pass on a variable defined in java (for example a string) as a argument to the shell command, how can I do that? My code looks something like this. I want two files to be created (touched) by name 123 & 234.
public class ExecShellCmds {
public static void beginWrite() {
String var1 = "123";
String var2 = "234";
String s = null;
try {
String[] cmd = {"/bin/bash", "-c",
"touch var1;"
+ "touch var2;"
};
Process p = Runtime.getRuntime().exec(cmd);
}}