A customer of mine asked how he could determine, from /etc/profile at login time, the IP address of remotely-connected telnet users: He wanted to be able to figure out the general area they were logging in from - the office? one of several warehouses? etc. - to determine things like default printers for their business application.
This is not as easy as it sounds. There's no direct network call to make, because the shell itself is not connected to the network (it's insulated by a pseudo-tty), and the indirect methods are not widely portable. This information is usually found in the utmpx structure, but is not always readily available (the who command on SCO UnixWare doesn't seem to expose this information).
So I wrote a program, whoamIP, to make a best effort at retrieving this information, and so far it works properly on SCO UnixWare, SCO Open Server, and on Linux.
Feedback (especially on portability issues) is welcomed.




