07-21-2023, 06:44 AM
I am trying to spawn an external process `phantomjs` using node's `child_process` and then send information to that process after it was initialized, is that possible?
I have the following code:
var spawn = require('child_process').spawn,
child = spawn('phantomjs');
child.stdin.setEncoding = 'utf-8';
child.stdout.pipe(process.stdout);
child.stdin.write("console.log('Hello from PhantomJS')");
But the only thing I got on the stdout is the initial prompt for phantomjs console.
phantomjs>
So it seems the `child.stdin.write` is not making any effect.
I am not sure I can send additional information to phantomjs ater the initial spawn.
I have the following code:
var spawn = require('child_process').spawn,
child = spawn('phantomjs');
child.stdin.setEncoding = 'utf-8';
child.stdout.pipe(process.stdout);
child.stdin.write("console.log('Hello from PhantomJS')");
But the only thing I got on the stdout is the initial prompt for phantomjs console.
phantomjs>
So it seems the `child.stdin.write` is not making any effect.
I am not sure I can send additional information to phantomjs ater the initial spawn.