title: How to open a OSX Terminal Window from Java and execute bash command
body: <p>As the title states I have been attempting to spawn a simple OSX terminal window and issue a series of batch commands but to no avail. Here is a summary of a couple things I have tried thus far</p>
  
  <p>1)Firstly I tried the open command:</p>
  
  <pre><code>Process p = Runtime.getRuntime().exec("open -n -F -a /Applications/Utilities/Terminal.app --args ls");
  </code></pre>
  
  <p>Whilst the preceding code DOES open a terminal window the argument is NOT passed.</p>
  
  <p>2)Next I dropped the "open" command and attempted to execute the terminal app directly passing in the arguments as part of the statement:</p>
  
  <pre><code>Process p = Runtime.getRuntime().exec(new String[]{"/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal","ls"});
  </code></pre>
  
  <p>Again, this opened the terminal window but the the list files "ls" bash command was not executed.</p>
  
  <p>3)Finally I tried executing the commands directly without specifying the Terminal app:</p>
  
  <pre><code>Process p = Runtime.getRuntime().exec("ping -c 3 google.com;"); 
  </code></pre>
  
  <p>Here the reverse was the case the commands ARE executed as specified but the terminal window is NOT displayed it would seem that this method requires that the caller obtains and processes the inputstream from the process in order to see the output produced by the terminal.</p>
  
  <p>Can't think of any further approaches to try at this point to simply open a terminal window and execute a series of batch commands programmatically, any pointers (no pun intended) would be very much appreciated.</p>