hex705

the first creature to discover water was likely not a fish

OSX Command Line with Processing

leave a comment

It is possible to access Unix Terminal commands (command line) on a Mac (OSX) through Processing.  This example uses the say command and then open to open two applications.  Note that parameters are in a String array (String[]) can can be changed with standard array calls.

NOTE: This example assumes you have google earth and Arduino installed in the applications folder. If you are having trouble, try full paths to applications you are opening.

Based on processing thread:
http://processing.org/discourse/yabb2/YaBB.pl?num=1237204442

Sample Code

DOWNLOAD EXAMPLES

 

// OSX command line in Processing
// based upon
// http://processing.org/discourse/yabb2/YaBB.pl?num=1237204442

// see also
// http://hintsforums.macworld.com/archive/index.php/t-2597.html

// steve daniels, hex705, jan 2011.

void setup() {
  size(300,300);
}

void draw() {

  // nothing here -- click mouse to make it all happen

}

void mousePressed() {
  // on command line-->  say "Hello World"
  String[] speak = {
    "say", "opening google earth"
  };
  exec(speak);

  String[] openApp = {
    "open", "-a", "google earth"
  };
  exec(openApp);

  // opens another App
  openApp[2] = "Arduino";
  exec(openApp);
}

Written by hex705

February 1st, 2011 at 11:35 am

Posted in bridges