I need to execute a batch CLI commands inside the only in one child process. For example, suppose i have these shell commands:
echo 1
echo 2
echo 3
As i know, the child_process.exec not really fits in my case because it will create child process per command. I could concatenate these commands via && and run as a shell script via child_process.spawn - but, again, my purpose is to handle each command separately, not just like the whole shell script.
Thanks for any suggestions and tips.
It turns out that i can send commands to the
child_process.spawnprocess:That's exactly what i need.