Launching a Processing sketch with shell

Kenneth Newby's icon

Greetings Hive Mind,

I'm trying to send a shell command that runs a Processing sketch. The command works in Terminal but not in shell. I'm wondering if anyone can help me understand why this doesn't work.

Here's the command:

processing-java --sketch=/Users/kennethnewby/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture --run

Thanks.

Kenneth Newby's icon

A little more information to share on this. If I send the processing.java part of the command by itself shell responds with: sh: processing-java: command not found. Terminal *does* find it however. What's the difference?

Source Audio's icon

you need to send full path to all non standard executables.
Like /Applications/Processing/xy/processing-java an than the rest
Shell needs slash based path to work.
best use conformpath slash boot prepended to executable path.

pdelges's icon

You probably have to write the full path of the processing-java exe. From what I found on the web, it is located in /usr/local/bin (I can't test myself), so your command should look like :

/usr/local/bin/processing-java --sketch=/Users/kennethnewby/Documents/Processing/libraries/video/examples/Capture/GettingStartedCapture --run

LSka's icon

The issue here is the PATH variable. When you type a command in a terminal, the shell (Bash in the case of MacOs's Terminal, sh in the case of [shell]) looks for it in the paths stored inside the PATH variable.
You can try sending the "echo $PATH" command to [shell] and you'll see the result is /usr/bin:/bin:/usr/sbin:/sbin
processing-java is in /usr/local/bin. That's why [shell] can't find it.
In standard shells you can add a path to the PATH variable using the "export" command, but I tried it and it's not working with [shell].
So you just have to specify the full path for processing-java, which is /usr/local/bin/processing-java

Kenneth Newby's icon

The path to the processing-java executable is, indeed, /usr/local/bin/processing-java

The Processing IDE is currently broken with respect to sketches that need to access the camera. I've now got a simple drag and drop solution in Max to launch these sketches using Max.

Thanks to all three of you for the help!

Here's the solution for anyone else who uses the camera in their Processing sketches:

Max Patch
Copy patch and select New From Clipboard in Max.