Hostname of where any windows is opened ?

Is it possible to get the hostname of the server we are currently working on (physically) even if we have rlogged/tn to another one ?

There is this DISPLAY variable we always have to setup everytime we log to a server (anyone). It has to be set to the name of the server we are physically working on. Its a bit annoying having to do this all the time. The purpose of this variable it to use VPRINT/BPRINT command that print the content of the window we point at. It has to know on which server that window is.

ex:

I am physically on Server-A, I open up a xterm on it, in it I telenet to Server-B. If I need to print anything from that window, then I need to set DISPLAY=Server-A on Server-B.

I am physically on Server-C, I am working on an xterm logged on to that server, I do an rlogin to Server-D. If I need to print anything from that window, then I need to set DISPLAY=Server-C on Server-D.

Test if a

who am i

shows from which host you are logged in. On AIX I get this:

root@host2> who am i
root        pts/1       Oct 23 13:51     (host1)
root@host2:/root> who am i| sed 's/[^(]*(\([^)]*\))/\1/'
host1

You could use that in your command to export DISPLAY.

Works only on the first rlogin.

I am on Server-A
Open up an xterm
log on to Server-B
who am I shows Server-A
on that same window I do rlogin Server-C
who am I shows Server-B

We have 22 servers in total but physically work on 2 of them. We frequently go from servers to servers through windows

"who am i" did it right, as supposed. From your 1st post it was explained there is only 1 server "hop" involved. Hopping further to the next host ie. start on A --- ssh ---> B --- ssh ---> C can't be displayed/checked.
What about typing exit when done on host B and then (back on A) ssh to host C? So "who am i" would give you the needed output in that case. Or is that not possible for the things you do on the boxes?