tpresley / node-remote-exec

Execute shell commands on one or more remote computers via SSH
MIT License
15 stars 6 forks source link

what's the best way to programmatically respond to output? #3

Open faceyspacey opened 9 years ago

faceyspacey commented 9 years ago

would I do something like this to respond to each output line:

var connection_options = {
  stdout: function(outputLine) { //do something here},
}
ashish00076 commented 6 years ago

@faceyspacey I believe you wish to add a function to the stdout handler. The best way to do that would be to pass an object to stdout with a function property with the name of write.

Something like this :

`var connection_options = {

    port: 22,
    username: 'sample_user',
    password: 'sample_password',
    stdout: {
        write : function(stream){
            let data = stream.toString('utf8'); 
                            console.log(data);
        }
    }
};

`

Hope this helps.

Cheers, Ashish Deshpande