Re: get logged in username



You'll need to get the owner of the running process which should be your
'admin' in this case.

If you're using a bash script, you could use "id", which will return
information about the user, like groups and uid. id -u returns my
userid, id -un returns my username. (GNU Coreutils 6.10)

If you're using another script, Python, PHP and PERL have built in
functions to obtain the current user.

If you are working in C, this might help you.
(Disclaimer: I'm not a C programmer)
http://www.gnu.org/software/libc/manual/html_node/Users-and-Groups.html#Users-and-Groups

Good Luck
~k

On Thu, 2009-09-17 at 11:15 +0430, Mohsen Alimomeni wrote:
Hi,

How can I get the logged in username under remote command execution? I
am using openssh version 4.0 under fedora core 4.

more explanation:
when I do "ssh admin@host", I can get the username "admin", by the
command "who -m", since there is tty which the username is assigned to
it. But suppose I want to execute a remote command "ssh admin@host
myprog", I want to get the username inside the myprog. The command
"who -m", doesn't work because no tty is created for the user.
How can I get the username in this case?

Regards,
--
__ \ /_\\_-//_ Mohsen Alimomeni



Relevant Pages

  • RE: get logged in username
    ... How can I get the logged in username under remote command execution? ... myprog", I want to get the username inside the myprog. ... doesn't work because no tty is created for the user. ...
    (SSH)
  • get logged in username
    ... How can I get the logged in username under remote command execution? ... myprog", I want to get the username inside the myprog. ...
    (SSH)
  • Re: get logged in username
    ... How can I get the logged in username under remote command execution? ... am using openssh version 4.0 under fedora core 4. ...
    (SSH)
  • Re: Newbie Alert: subprocess.call
    ... to get username and passwords from Linux users to send as options to ... I came across the easygui module and ... does when sent from the BASH script below. ... Error 7: TCP/IP connection: unable to resolve host. ...
    (comp.lang.python)
  • Re: get logged in username
    ... How can I get the logged in username under remote command execution? ... doesn't work because no tty is created for the user. ...
    (SSH)