title: Running external script from Java application on OS X
body: <p>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.</p>
  
  <p>What works (Windows):</p>
  
  <pre><code>String[] commands = {
      "\"" + _appDataDir + "\\Temp\\Workers\\" + _batchName + "\"", 
      "\"" + _appDataDir + "\\Temp\\frame%d.jpg\"", 
      "\"" + _fileName + "\""};
  proc = rt.exec(commands);
  </code></pre>
  
  <p>So I have the following for OS X:</p>
  
  <pre><code>String[] commands = {
      _appDataDir + "/Temp/Workers/" + _batchName,
  _appDataDir + "/Temp/Workers/mac-ffmpeg",   
  _appDataDir + "/Temp/frame%d.jpg", 
  "\"" + _fileName + "\""};
  proc = rt.exec(commands);
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>I also tried ProcessBuilder as below (both with and without the "/bin/bash/, -c" bits):</p>
  
  <pre><code>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();
  </code></pre>
  
  <p>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!</p>