node.js - node js interact with shell application -


there plenty of node js examples on online how spawn child process , catch result string own processing.

but...

i want 'interact' child process. example, how write node js application starts calling 'python' , types statement '1+1', lets me catch result '2', before proceeding type arbitrary statement '4+4'?

(and 'type' i'm assuming require streaming data stdin process uses).

var child = require('child_process'); var ps = child.spawn('python', ['-i']); ps.stdout.pipe(process.stdout); ps.stdin.write('1+1'); ps.stdin.end(); 

works treat!


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -