Obtain the remote username?

Hi,

I'm new to Unix scripting so I'm hoping someone can help me out.

I have trawled the web trying to find an answer to this but have not been able to find out anything.

I'm trying to create a script that when supplied with a hostname, will find out information about the remote machine.

I know the admin account details on the remote machine, and can obtain the IP address no problem, but I'm having trouble finding out how to obtain the username of the person that is currently logged into the machine.

Just so I can make this clear, I do not want to copy the script onto the remote machine and run it (as in copy the script to the machine and 'whoami'). I actually want to try and obtain the username remotely.

I realize that this may not be possible due to security reasons.

Any ideas?

Many thanks for any help.

You could use the ident protocol, but this can only tell you which user is the owner of a connection. Another way may be to ssh into the other host and running 'who' to get a list of all users currently connected.

Many thanks Pludi for the reply. ident may be the way to go with this.

I did think about the ssh solution but unfortunately that would mean having to go around and turning on ssh on all the computers that we administer.

Once again thanks for the help.