I'm unsure if this is an bug or if I'm doing something wrong.

I need to capture the output of the built-in Python server, but spawn() 
doesn't seem to receive any data even though it shows in the console when 
inheriting the stdio.

This doesn't output anything to the console:


var spawn = require('child_process').spawn;

var cp = spawn('python', ['-m', 'SimpleHTTPServer', '8010']);

cp.stdout.setEncoding('utf8');
cp.stderr.setEncoding('utf8');

cp.stdout.on('data', function (data) {
  console.log('stdout', data);
});

cp.stderr.on('data', function (data) {
console.log('stderr', data);
});

cp.on('close', function (data) {
console.log('close', data);
});

cp.on('exit', function (data) {
console.log('exit', data);
});



While this outputs: `Serving HTTP on 0.0.0.0 port 8010 ...`


var spawn = require('child_process').spawn;

spawn('python', ['-m', 'SimpleHTTPServer', '8010'], {
  stdio: 'inherit'
});



Thoughts?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to