Hi i have a shell script named script .sh that create maven project having parent pom and multiple modules under it as follows:

 mvn archetype:generate -DgroupId="com.low.co" -DartifactId="tool-release" -DarchetypeGroupId=org.codehaus.mojo.archetypes -DarchetypeArtifactId=pom-root -DarchetypeVersion=RELEASE
cd yeti-release
 mvn archetype:generate -DgroupId="com.low.cp" -DartifactId="tool-api" -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE
 mvn archetype:generate -DgroupId="com.low.cp" -DartifactId="tool-impl" -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE
 mvn archetype:generate -DgroupId="com.low.cp" -DartifactId="tool-rest" -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE
 mvn archetype:generate -DgroupId="com.low.cp" -DartifactId="tool-service" -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=RELEASE 

I want to run this script from java code i am using mac osx i tried every thing my code that is opening this script is as follows:

   final File scriptDirectory = new File("src/main/resources/");  
   final String shellScript = "./script.sh"; 
   ProcessBuilder pb = new ProcessBuilder();

when i change script.sh it is not showing console nor executing any of the commands in the shell script
any suggestions pls

Recommended Answers

All 2 Replies

Member Avatar

A stab in the dark here, but have you tried using RunTime instead? I think you can accomplish the same by (please note that the syntax may be off):

Runtime.getRuntime().exec("/bin/bash -e " + shellscript);

More info HERE.

ProcessBuilder was intended as a replacement for Runtime exec, so maybe that will work, but it is a step backwards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.