I'm having real issues getting an external script to run from my Java application on OS X 10.8. It works on Windows, so not sure what I'm doing wrong for OS X.
What works (Windows):
String[] commands = {
"\"" + _appDataDir + "\\Temp\\Workers\\" + _batchName + "\"",
"\"" + _appDataDir + "\\Temp\\frame%d.jpg\"",
"\"" + _fileName + "\""};
proc = rt.exec(commands);
So I have the following for OS X:
String[] commands = {
_appDataDir + "/Temp/Workers/" + _batchName,
_appDataDir + "/Temp/Workers/mac-ffmpeg",
_appDataDir + "/Temp/frame%d.jpg",
"\"" + _fileName + "\""};
proc = rt.exec(commands);
This works when there are no spaces in the filename, but fails when there are spaces with a "java.io.IOException: Bad file descriptor" error.
At the moment, I've changed all the paths to have no spaces as an easy fix, but I don't have control over the fileName string as this is selected by the user from a save dialog. I've tried with and without double quotes around fileName but neither make any difference.
I also tried ProcessBuilder as below (both with and without the "/bin/bash/, -c" bits):
ProcessBuilder proc2 = new ProcessBuilder(
"/bin/bash",
"-c",
_appDataDir + "/Temp/Workers/" + _batchName,
_appDataDir + "/Temp/Workers/mac-ffmpeg",
_appDataDir + "/Temp/frame%d.jpg",
"\"" + _fileName + "\""
);
proc = proc2.start();
but this gives the same error. As far as I can tell I'm doing everything that's being suggested in other similar questions, but nothing is working. Any ideas would be appreciated!