Node.js: STDIN

From delarco wiki
Jump to navigation Jump to search
var stdin = process.openStdin();

stdin.addListener("data", function(d) {
// note:  d is an object, and when converted to a string it will
// end with a linefeed.  so we (rather crudely) account for that  
// with toString() and then trim() 
	console.log("you entered: [" + d.toString().trim() + "]");
});