Skip to content

Get input data on output listener method #184

@joeyzhao0113

Description

@joeyzhao0113

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions