I can not get any output in the following code:
var spawn = require('child_process').spawn,
script = 'ftp',
child = spawn(script);
child.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
child.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
child.on('close', function (code) {
console.log('child process exited with code ' + code);
});
It works for regular scripts like 'ls', 'pwd', etc. But not for interactive programs such as 'ftp', 'telnet'. Any suggestions?
Edit:
Take another script, for example:
name = raw_input("your name>")
print name
When this script appears, I want to get a "your name" prompt with a data event so that I can contribute something to stdin.
The problem is that I received nothing in the data event, and it seemed that none of these events were triggered.
source
share