ahmadawais / corona-cli

🦠 Track the Coronavirus disease (COVID-19) in the command line. Worldwide for all countries, for one country, and the US States. Fast response time (< 100ms). To chat: https://twitter.com/MrAhmadAwais/
https://NodeCLI.com
MIT License
1.85k stars 191 forks source link

How to get cli output on web page by command? #107

Open qadeesz opened 4 years ago

LinkSake commented 4 years ago

If your web is using NodeJS as the backend you can use the child_process module that comes with Node.

E.g.

var exec = require('child_process').exec, child;

child = exec('corona usa',
    function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
             console.log('exec error: ' + error);
        }
    });
 child();

I found about it on this Stack Overflow thread