Process-Libraray: difference between run() and runShellCommand()


one question about the Process-library: is there any difference between starting a Process p using


and using

p.runShellCommand("cmd par");


Thx for help,

There are some subtle differences. The first method is more flexible and gives you greater control (including the ability to run the command asynchronously in the background while the sketch continues to run) while the second method involves less typing.

The biggest difference is that the first one will run the "cmd" directly, passing it "par" as a parameter, while the second one will run an instance of /bin/ash, passing it two parameters: "-c" to signal that it should run a command, and "cmd par" as the command to be run.

So if you are running an external process, like a Python script, the first method is a bit more efficient since it runs the script directly, while the second method runs a command interpreter, which then runs the script.

On the other hand, if you are trying to run a command that is part of /bin/ash itself (like a busybox command) then only the second version will work unless you use /bin/ash as the command in the begin() call.

Thank you for the fast and detailed answer! :slight_smile:

So when executing a shell-script which itself starts with #!/bin/ash it would make more sense to start it with