I'm getting the below error when trying to run a shell script from java in Eclipse.
I just created a text file on my local and wanted to see if it will run.
new ProcessBuilder("C:/Users/myDir/Desktop/ss1.sh").start();
You cannot run a shell script on Windows directly as it is no executable in the Windows sense (only .exe, .com, .cmd and .bat are executables).
Call bash.exe or sh.exe and use your script as the first parameter.
new ProcessBuilder("path-to-bash/bash.exe C:/Users/myDir/Desktop/ss1.sh").start(); or new ProcessBuilder("path-to-bash/bash.exe -c C:/Users/myDir/Desktop/ss1.sh").start();Following MrTux comment I wrapped the py script that I was calling from groovy in a bat file and, voilà!, it works.
Calling directly the py script from groovy
def proc = "C:\\MyDir\\myScript.py param1 param2 param3".execute()
proc.waitFor()
def result = proc.in.text
def error = proc.err.text
it fails
Wrapping the py script in a bat file def proc = "C:\MyDir\myScriptWrapper.bat param1 param2 param3".execute()
works
Wonder why this behaviour in Windows is not better documented. And many thanks to MrTux