As of nodejs v12+ you can do this both synchronously and async on Linux, 
with:

process.getusername = function() {
var username =  require('child_process').execSync( "whoami", { encoding: 
'utf8', timeout: 1000 } );
return String(username).trim();
}

Be warned that this is the synchronous example, so bad for web servers!



On Thursday, September 23, 2010 at 4:32:26 AM UTC-5, robb1e wrote:
>
> Hi, 
>
> From the process global I can see that I can get the current user id, 
> but is there a way to get the current username? 
>
> Thanks 
>
> Robbie

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/bf704afa-8d0d-421b-913e-df2f99a941e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to