Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!sahayman From: sahayman@iuvax.cs.indiana.edu (Steve Hayman) Newsgroups: comp.windows.x Subject: Figuring out the right DISPLAY variable when you rlogin. Message-ID: <19688@iuvax.cs.indiana.edu> Date: 15 Apr 89 00:44:58 GMT Reply-To: sahayman@iuvax.cs.indiana.edu (Steve Hayman) Organization: Computer Science Department, Indiana University Lines: 60 Many X users that I've seen seem to have something like this in, for instance, a .login file on a big Vax, to figure out what to set their DISPLAY environment variable to whenever they rlogin from a workstation: if ( $TERM =~ xterm* ) then echo -n "What workstation are you using ? " # oops, I got this line wrong the first time I posted this... set host=$< setenv DISPLAY ${host}:0 endif or if they really want to get fancy and try to figure it out automatically, if ( $TERM =~ $xterm* ) then # "who am i" shows something like # iuvax!sahayman ttyrd Apr 14 12:25 (cssun1) # so cut out the remote host part set rhost=`who am i | sed -e 's/.*(//' -e 's/.)*$//'` setenv DISPLAY ${host}:0 endif Unforunately the latter technique is a kludge at best, and fails if you do a chain of rlogins, since the "who am i" has no way of telling you the original machine that you started on. [Please stop me right here if there's some better way to do this that I don't know about. Thanks] A suggestion. xterm knows what the right DISPLAY is, since xterm is actively using that information. How about we extend the xterm protocol a bit so that there is some escape sequence you can send it that will case xterm to echo back what its idea of the DISPLAY variable is. That way, your .login file could simply echo a few bytes and read back a string and set the DISPLAY according to that string The same idea as eval `resize`. This would work across chains of rlogins, since the escape sequence would be interpreted by the original xterm and not by anything on any of the intervening hosts. As an experiment, I made this particular modification to our own xterm here, having more or less chosen a suitable escape sequence at random. In fact I made it a bit more general, ] 999 ; STRING makes xterm echo back the value of its environment variable STRING. (If one was gung ho, one could also make it echo back other xterm private variables such as the current window name, etc etc, but DISPLAY is about the only thing I can think of a use for at the moment.) Perhaps something like this would be a worthwhile addition to the standard xterm. Anybody else got a better way to set your DISPLAY? ..Steve -- Steve Hayman Workstation Manager Computer Science Department Indiana U. sahayman@iuvax.cs.indiana.edu (812) 855-6984