I'm trying to run shell script thru Java in Mac OS. The shell script has git clone command clone a repository.
I have tried using process builder API. It's not giving any exception though but the repo is not cloning when I run the code.
public class Test {
public static void main(String[] args) throws IOException {
Process p;
try {
List<String> cmdList = new ArrayList<String>();
cmdList.add("/Users/Folder/AnotherFolder/Another/Final/clone.sh");
ProcessBuilder pb = new ProcessBuilder(cmdList);
p = pb.start();
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line;
while((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
Expecting to clone git project in the path, but not giving any output or Exception.