Hi Nathan, On Apr 23, 4:07 pm, Nathan Rajlich <nat...@tootallnate.net> wrote: > But it sounds like maybe your're expecting to enter the REPL in this case, > and enter commands one-at-a-time?
I have a program occasionally piping commands, one-at-a-time, into node's stdin which I want to be executed as soon as possible. Like in the REPL. The commands need to be executed in the same node instance, as they share state, so I can't just close the pipe and start a new node for subsequent commands. I don't need the REPL prompt, but it won't do any harm. > I'm node v0.7.7 the "-i" flag was added > to make this case work. So with node v0.7.7 or above: > > $ cat | node -i I think that sounds like what I need. But... that's the unstable branch. Do you have any experience with that? How unstable is it? Is it likely to crash on me or cause other problems? > But this "buffering" behavior in general doesn't happen, it's only because > you were attempting to pipe a script into node with no script file to run > itself, so it waits for a script from stdin and executes that. If you try > the same thing again with a simple script (test.js): > > process.stdin.setEncoding('utf8') > process.stdin.resume() > process.stdin.on('data', function (command) { > console.log('got command: %s', command.trim()) > }) > > and run it: > > $ cat | node test.js So I could just change the console.log() to an eval() in that test.js and that should work. OK, thanks. Adam -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en