I'm using MeteorJS.
I'd like to call a bash command from the javascript server side. This seems possible with nodeJS: http://www.dzone.com/snippets/execute-unix-command-nodejs
However, I can't find something similar with meteorJS. I'd like something like that :
if(Meteor.isServer){
...
exec("myCommand");
}
You can also use child_process.spawn().
Read More about executing a UNIX command with Meteor.
spawn = Npm.require('child_process').spawn;
command = spawn('ls', ['-la']);
command.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
command.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
command.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
If you take the calls to require from the sample and prefix them with
var sys = __meteor_bootstrap__.require('sys');
it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With