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

166
Views
Executing a shell script with interactions with child_processes in nodeJS

I am building a small custom node CLI application with user input using Inquirer and when after a specific chain of inputs, I would like to execute a script that has itself interactions as well. Right now I use the child_processes.exec() function to execute the command, which does work, however my terminal does not render the program and ends up stuck.

This code executes the external shell script:

cp.exec(
'svg-inliner', 
{
 cwd: iconsFolder, 
}, 
(err, stdout, stderr) => {
    if(err) throw err;
    if(stderr) {
      //...
       throw stderr;
    }
     if(stdout) return;
});

What it should do

What it currently does

Inquirer executes a callback once all the questions are answered from the termminal. Inside that callback I trigger a function that calls on the child_processes.exec().

inquirer.prompt(questions)
    .then(answers => {
      cp.exec();
    }

Is it actually possible to execute another CLI script from a Node.js CLI application?

Edit:

I created a .sh file that does what I wanted the exec to do. In that file I execute the node script followed by the svg-inliner command at works wonders.

node .index.js $1

svg-inliner
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!