How do I get the username in Java (ie, who -m in Java) (or Jython 2.1)
Posted
by amertune
on Stack Overflow
See other posts from Stack Overflow
or by amertune
Published on 2010-04-07T19:41:36Z
Indexed on
2010/04/07
19:43 UTC
Read the original article
Hit count: 225
Here's the situation. I have a jython 2.1 script in a shared account that needs to know who is calling it. In bash, I can simply use 'who -m' and it will give me the correct username.
I haven't been able to find anything in java (or jython) that would give me a similar result. Even trying to call Runtime.getRuntime().exec("who -m") doesn't do anything. When I try to read the InputStream from the process returned by exec, the stream is empty.
© Stack Overflow or respective owner