Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Respond to nodejs spawned child process

Been trying to respond to a CLI tool which prompts two questions before running so I tried to create a script for automation. Problem is: respond is not submitted. Searched this for hours and literally read every other stackoverflow question about this topic but none of these solutions seems to work. here's my code:

const moralis = spawn(
      `moralis-admin-cli connect-local-devchain --moralisApiKey ${process.env.MORALIS_API_KEY} --moralisApiSecret ${process.env.MORALIS_API_SECRET} --frpcPath ${process.env.FRPC_PATH}`,
      {
        shell: true,
      }
    );

moralis.stdout.setEncoding("utf8");
moralis.stdout.pipe(process.stdout);

moralis.stdout.on("data", function (data) {
 if (data.includes("What server")) {
   moralis.stdin.write("0" + "\n");
   moralis.stdin.end();
 }
});

running that just prints the prompt of the CLI tool and doesn't submit anything. If I use process.stdin.write it actually prints the 0 response but also doesn't submit it. From my understand the end call should actually submit my response? Also why don't I see the response in shell when I use moralis.stdin.write?

cheers!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!