bash = require('child_process').spawn '/bin/bash', []
console.log 'Spawned bash as pid ' + bash.pid
bash.stdout.on 'data', (data) ->
process.stdout.write data
I'd expect that the code above would read from bash and display to the process stdout. It doesn't. If I replace /bin/bash
with /bin/bash -c /bin/ls
I will get the output of ls
which I'd expect. Obviously this has something to do with bash
remaining open.
Any hints on how to read what bash
outputs without having to have the process terminate?
Use https://github.com/chjj/pty.js/
It works like a charm!