This can be done using node.js. Create a resting endpoint in nodejs and call the same from angular.Say:
$http.get(URL + "/script").then(function (req,response) {
...
write your code here
...
}
In node.js, use the following code snippets.
var sys=require('util');
var exec=require('child_process').sys;
var child;
// end point of rest
app.get('/script', function (req, res) {
child = exec("pwd", function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
}
source
share