I have the following code.
router.post('/',function(req, res, next) {
        var id=req.body.id;
        console.log(id);
    const testscript = exec('sh script.sh');
    testscript.stdout.on('data', function(data){
        console.log(data);
        // sendBackInfo();
    });
    testscript.stderr.on('data', function(data){
        console.log(data);
        // triggerErrorStuff();
    });
        res.redirect('/Visualise');
});
I need to completely execute my shell script and then redirect to '/Visualise'. Some part of code in the next page uses the output file generated by shell script. It is redirecting before executing the shell script completely and i am getting a file not found error. How can i execute synchronously. Please make the required changes in the above code to do so. Thank you.
 
     
    