i run a script shell from springboot application , it show this error when i run the spring application :
Cannot run program "src/main/java/com/springapp/app/bach/scripts/test.sh": CreateProcess error=193, %1 is not a valid Win32 application
#!/bin/bash
echo "Hello World !"
this is the controller which execute the commande :
@Override
public String runScript(String pathScript) throws IOException, InterruptedException {
try {
Process p = Runtime.getRuntime().exec(pathScript);
InputStream is = p.getInputStream();
StringBuffer sb = new StringBuffer();
int i = 0;
while ((i = is.read()) != -1) {
sb.append((char) i);
}
return sb.toString();
}
catch (IOException e){
e.printStackTrace();
}
}
the main applicattion :
String message = runScript.runScript("src/main/java/com/innovsys/qopsbe/bach/scripts/test.sh");
System.out.println(message);
I did my research on google i found a solution, they told me to put a "cmd" just before the path of the file
but it didn't work for me !!