Skip to content

Instantly share code, notes, and snippets.

@dduvnjak
Created July 21, 2013 22:03
Show Gist options
  • Save dduvnjak/6050195 to your computer and use it in GitHub Desktop.
Save dduvnjak/6050195 to your computer and use it in GitHub Desktop.
var exec = require('child_process').exec;
function execute(command, callback){
exec(command, function(error, stdout, stderr){ callback(stdout); });
};
module.exports.getUser = function(callback){
execute("whoami", function(name){
callback({ name: name.replace("\n", "") });
});
};
this.getUser(function(user) {
if (user.name !== 'root') {
console.log("not root!");
process.exit(1);
}
console.log(user.name);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment