I want to control the server and display the top output of the command in real time on a web page. error: initializing curses occurs after starting the program on Mac OS. I donβt know how to deal with this, my question is how to get the top output of the command in real time via Node.JS?
var spawn = require('child_process').spawn, com = spawn('/usr/bin/top', []); var io = require('socket.io').listen(5555); com.stdout.on('data', function(data){ io.sockets.emit('get result', data); } ); com.stderr.on('data', function(data){ console.log('stderr: ' + data); });
source share