I am using pty.js in a nodejs application to emulate a interactive terminal. But the I got the input data in the output listener method. Is there a way to get the output data only?
Below is my source code:
var pty = require('pty.js');
var term = pty.spawn('bash', [], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
});
term.on('data', function(data) {
console.log(data);
});
term.write('echo hello\n');
when running above code, I can see the output:
$ node official.js
echo hello
bash-3.2$ echo hello
hello
bash-3.2$
from the above output you can observe that the input command echo hello got printed twice in term.on('data' ...) function. Is there a way to get ride of the input data from the output listener method?
I am using
pty.jsin a nodejs application to emulate a interactive terminal. But the I got the input data in the output listener method. Is there a way to get the output data only?Below is my source code:
when running above code, I can see the output:
from the above output you can observe that the input command
echo hellogot printed twice interm.on('data' ...)function. Is there a way to get ride of the input data from the output listener method?