[comp.windows.x] How do I get hostname of display in csh script?

gjf00@duts.ccc.amdahl.com (Gordon Freedman) (02/13/91)

I am writing my own version of xrsh which allow specifying a userid as well
as the remote host. It also uses csh rather than sh as xrsh does. The idea
is to remotely run an x application from an rhost as painlessly as possible.
This requires a few things, two of which I have questions about:

1) How do I get the name of the display device? Sometimes the env variable
   DISPLAY is correct, but other times it is not, so I have to obtain the
   actual display name (the ip address is probably ok too). I am using this
   for the "-display ..." parameter to the x program running on the rhost.
   One thing I can do is lookup the utmp entry indexed by ttyslot, but this
   only works sometimes. An example of where it doesn't work is when you
   are logged into compute host "A" from xterm "B", and rlogin to host "C".
   Indexing into utmp gives "A" rather than "B", which is not the display
   device.

2) How can I determine if the display device is an xterm which does not
   require doing "xhost + rhost", as opposed to a display device attached
   directly to a workstation (which will require xhost + rhost). We don't
   use any security on the xterms, so I don't know if there are cases where
   "xhost + rhost" is even meaningful for an xterm. Our workstations do
   need to do the "xhost +", so I wrap the rsh execution within "xhost + rhost"
   and "xhost - rhost". For xterms, this is unneccessary so I want to skip it.

We are using mostly SPARC IPCs running X11-R4.0. Please email replies to
gjf00@duts.ccc.amdahl.com, as I don't always get to read this newsgroup.
Thanks in advance!


--
Gordon Freedman: gjf00@duts.ccc.amdahl.com
Disclaimer: My opinions! Not my employers!