# Executing Sketch via Linux Command Line?

**URL:** <https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839>\
**Category:** Processing\
**Created:** [December 23, 2018, 7:43am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839 "2018-12-23T07:43:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyquil](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@nyquil](https://discourse.processing.org/u/nyquil)\
**Post date:** [December 23, 2018, 7:43am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/1 "2018-12-23T07:43:17Z")

</div>

Anyone have experience using sketch to bring up what you’ve created via the linux command line?

I found this online, but it’s not working for me for some reason.

> **[processing/processing](https://github.com/processing/processing/wiki/Command-Line)**
>
> Source code for the Processing Core and Development Environment (PDE) - processing/processing

I downloaded the tgz processing file from the official site and then extracted it into my ~/ directory. From the processing IDE , if i open the sketch folder, it seems to be by default set to /tmp on my linux system, but using processing ide also creates a sketchbook folder in my home as well, but how exactly do I use the command line to execute sketch? can’t seem to get it to work ☹

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 23, 2018, 8:17am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/2 "2018-12-23T08:17:15Z")

</div>

well, it should run, so might be that you type the command wrong?  
how we could help if you not show the command / and the error you got.  
like with a screenshot?

 ![2018-12-23_15-16-14_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5b9d060c04cec53fb9fa9223cded504a4716f80e.png)

---

<div class="post-metadata">

**Author:** ![nyquil](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@nyquil](https://discourse.processing.org/u/nyquil)\
**Post date:** [December 23, 2018, 8:45am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/3 "2018-12-23T08:45:31Z")

</div>

extracted processing-3.4-linux64.tgz to ~/  
sketch dir = ~/home/rue/sketchbook/sketches/

i created a test.pde in ~/home/rue/sketchbook/sketches/test.pde  
via text editor.

executed ./processing-java --sketch=/home/rue/sketchbook/sketches/ --force --run  
like it described in the github page  
however, i’m seeing this result:

…[https://imgur.com/a/nAsT9xM](https://imgur.com/a/nAsT9xM)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 23, 2018, 9:07am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/4 "2018-12-23T09:07:40Z")

</div>

for the install procedure??  
i miss you do the install.sh thing?  
what procedure you are following?

//\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
sorry, that would not run with IDE or from command line.

the path to the DIR of the sketch would be

> /home/rue/sketchbook/sketches/test

the path to the sketch would be

> /home/rue/sketchbook/sketches/test/test.pde

the call only need the path info

```auto
processing-java --sketch=/home/rue/sketchbook/sketches/test --run

```

also the ./ should tell linux what?

> pi@RPI3BP:~ $ ./processing-java  
> bash: ./processing-java: No such file or directory

---

<div class="post-metadata">

**Author:** ![nyquil](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@nyquil](https://discourse.processing.org/u/nyquil)\
**Post date:** [December 23, 2018, 9:24am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/5 "2018-12-23T09:24:37Z")

</div>

hmm so seems like the file name i’m working on has to match the folder name?  
so that would mean the command:

```auto
processing-java --sketch=/home/rue/sketchbook/sketches/test --run

```

would have to be changed every time to reflect the new file i’m working on? since the new file name will need its own identical folder name?

is there no way to just have one folder for keeping all the files?

i’m using ./ because i haven’t set the those processing shell scripts as aliases in my .bashrc so globally, the system doesn’t know about these shell scripts (commands) yet. so ./ allows the system to know i’m trying to run this particular script in this folder.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 23, 2018, 9:26am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/6 "2018-12-23T09:26:31Z")

</div>

hm, possibly you should start with the IDE first  
it is organizing all that for you

 ![2018-12-23_16-29-12_snap](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0b29c5d1d437c05ea0a8a88a3dace85f4393a2b0.png)

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [December 23, 2018, 10:59am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/7 "2018-12-23T10:59:29Z")

</div>

If you want to have a bunch of sketches in the same folder and be able to run them, you could use a bash script for launching them. Lets assume we have these files and folders somewhere on our computer:

```auto
$ ls
data/
runp5.sh
test1.pde
test2.pde

```

The data folder can contain images, sounds etc needed by your sketches.

I have two working sketches (test1 and test2) and then my launcher script `runp5.sh` that looks like this:

```auto
#!/bin/bash

# The argument with .pde removed
base=${1%.pde}

# The folder where we will store the sketch
p5path="/tmp/$base"

# Remove the folder if it exists...
rm -rf $p5path

# ...and create it again
mkdir $p5path

# Symlink the data folder
ln -s "$(realpath data)" $p5path/data

# Symlink the pde file
ln -s "$(realpath $1)" $p5path/$1

# Run!
processing-java --sketch=$p5path --run

```

This script must be executable (you can do `chmod +x runp5.sh`)

Once things are set up like this, you can launch the sketches like this:

```auto
./runp5 test1.pde
./runp5 test2.pde

```

What does it do? basically it creates the required folder structure to run the sketch by using symbolic links, which is nice because they are tiny so it’s not copying any huge files you may have in `data`. Also nice because if you edit the files inside `/tmp` (say with the Processing IDE) changes are reflected in their original location.

But… it won’t work if your sketch uses multiple `pde` files, or in other cases I haven’t thought of.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [January 1, 2019, 3:37am UTC](https://discourse.processing.org/t/executing-sketch-via-linux-command-line/6839/8 "2019-01-01T03:37:58Z")

</div>

If you are trying to script multiple sketches and don’t mind exporting them first, then here is a previous related discussion of writing a launcher script for multiple sketches.

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/18397/launching-scripts)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

The example launcher script is python, not bash, and it uses the self-contained app form rather than the raw sketch with `processing-java`.

You might also be interested in programs for managing multiple sketches, like the Processing Showcase:

- [https://happycoding.io/examples/java/processing-in-java/processing-showcase](https://happycoding.io/examples/java/processing-in-java/processing-showcase)
