I am using the exec node while enabling the "Use spawn() instead of exec()?" option. I am running a command that starts a child process and waits for input (child process stays on until I send it an exit command or kill it). Is there a way to send input and interact with that open child process by the exec node?
There are many examples I have run into where I need to do this. One example is interacting with the bluetooth service on a raspi or other boards. For example, I first send the command bluetoothctl and then it takes me inside the bluetooth service so I can run other commands like scan on and so forth.
I prefer to avoid installing additional nodes and just work with what I have as much as possible.
The node-red-node-daemon node is designed exactly for this situation. It runs a "long running" process and accepts input to STDIN and provides STDOUT, STDERR like the exec node does. It can also be stopped and restarted if required.
Thanks a lot for the quick response! I am having trouble understanding how to use this node. So for example I would like to run the service bluetoothctl, then once it starts I want to send scan on and after 10 seconds I want to send scan off. Can you give me an example on how to do that? I am only able to send the one command bluetoothctl and it says "running" but then I am not sure how to give it inputs.
I am basically passing a string msg.payload as my child process input after starting the process/app with the daemon node. If anyone sees a better way of doing what I just did, please feel free to share!