to write to stdin from an already initialized process with Nodejs Child Process, we call trhe stdin.write
method.
For instance, we write
const spawn = require("child_process").spawn;
const child = spawn("phantomjs");
child.stdin.setEncoding("utf-8");
child.stdout.pipe(process.stdout);
child.stdin.write("console.log('Hello from PhantomJS')\n");
child.stdin.end();
to call stdin.write
to write to stdin.
And then we stop writing with stdin.end
.