Skip to content

Instantly share code, notes, and snippets.

@levidehaan
Created October 31, 2011 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levidehaan/1328912 to your computer and use it in GitHub Desktop.
Save levidehaan/1328912 to your computer and use it in GitHub Desktop.
using child_processes, if i create a new process,
ssh = spawn('ssh', ['root@remotehost.com']);
and then put a listener on stdout
ssh.stdout.on('data', function(data){
console.log(data);
});
and then send some stuff
ssh.stdin.write("ls -alh\n");
and
ssh.stdin.write("touch testing.txt\n");
and then toss another listener on, but this time a one time listener
ssh.stdout.once('data', function(data){
console.log(data);
}
it starts over at the begining of the socket output, instead of the next emit from stdout
so it essentially instantly outputs, because its grabbing existing data from stdout
is there a way to start it at the end of the socket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment