0

I'm a beginner in Node.js and also in programming. Perhaps I miss something very basic. I have two scripts which have to talk with each other in the command line. The first script gives numbers and the other makes some math and returns the answer. The first script was written by someone else and I don't know what is there. Te second script is mine. It reads the numbers in stdout and writes the answer in stdin. The first script "sees" the answer only after process.stdin.end(). But I have to read and write multiple times. What should I do? My code looks like this:

var process = shell.exec('node first.js', {async:true});
process.stdout.on('data', function(data) {
   process.stdin.write("" + evalStr(data) + "\n");
   process.stdin.end();
});

1 Answer 1

2

Use process.stdin.write(data + "\n") instead of using evalStr().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.