ip address of a client

A client(PC) connects to an unix server via terminal emulator.
How can I obtain that client's IP address?

The unix server is an old SVR4.2 (NCR) and the "who" command
does not show ip addresses.

I need a command or a shell script or a C/C++ program that will
help me to obtain the client's IP address.

Could anyone help me?

Depends heavily on the terminal emulator. If it's one in the truest sense of the name, they'll be connecting as though on a directly connected terminal - so no IP. In that case, you'd need to look on the emulator to find the IP.

If you mean a terminal emulator like a piece of software on their client machine and they come in over IP and talk to something that doesn't use login. Find the relevant process and see what IP's it's got open connections to.

Or have I misunderstood the question? :wink:

If I haven't misunderstood it too, the client's IP will appear somewhere in the logs.

Thanks for your answer.

The client connects to the server with telnet. i.e. on the terminal emulator
window of the client the user sees "login:" and then logs on to the unix server.

Below is what "ps" command displays - note that there is no ip, but just the termid - pts/29:
ka2d2 28144 28142 0 Nov 20 pts/29 0:00 -sh

I want to find out the ip of the client from which the user "ka2d2" logged in the server.

Ah, telnet clarifies things a fair bit.
If you can find a version of lsof for it you can use this to find the IP. Otherwise, I like sysgate's point that the IP will be in the logs at time of connection. So you can run the output of who through a grep of the logs (for the username and a login message), then tail off the last entry to get the IP.

"last" command may be helpful to you

Sumitpandya and all others, thank you for your answers.

I found the solution with the "last" command.