Setting the DISPLAY Environment variable

Setting the DISPLAY Environment variable

Post by Richard Leyto » Wed, 15 Nov 1995 04:00:00



A question I've been puzzling over for a while is:

How can I pass the DISPLAY environment variable when a user
logs into another machine?

We run a small Unix network here, and everybody is logging in
from a local Unix machine (running X) to one of the main machines
(with all the processing power). Unfortunately,
the setting for the DISPLAY environment variable is not working,
we're currently going on a grep of the `who` command using the
tty as the search key to get the source machine.

But a bug in Solaris 2.3 (or an unapplied patch... Any ideas?) means
that when a user logs out, the tty is still attached to their id,
even if somebody else later uses it. Its hit and miss that, after
the machine has been up for a while, that the tty information from
the who command is correct.

Add to this that when a shell is fired up from the log in, there is
no hostname attached to the tty in the who command, and some users
insist on setting their DISPLAY var within the .cshrc file and not
the .login

So, I was wondering, what tactics to you employ to pass the DISPLAY environment
variable around between machines? Is there some easy method that I'm missing?

I've scoured the FAQ and other sources to no avail (or I'm going blind and
have missed it), so maybe someone would care to enlighten me.

If anybody is curious themselves, let me know and I'll pass on a summary
of the information I find out. I'll post it here as well, like a good
usenet reader... ;-)

Thanks in advance,

Richard Leyton

--
Richard Leyton, AMS Management Systems Deutschland GmbH,
              Am Seestern 1, 40547 Duesseldorf, Germany.

WWW: http://www.brookes.ac.uk/~e0190404/home.html

Opinions are my own, and not representative of AMS.

 
 
 

Setting the DISPLAY Environment variable

Post by James A. Carha » Thu, 16 Nov 1995 04:00:00


 From the FAQ;

> 36)  How do I keep my $DISPLAY when I rlogin to another machine

> There are several ways to avoid having to do a "setenv DISPLAY ..." whenever
> you log in to another networked UNIX machine running X.

> A trivial solution, if your account is cross-mounted on both machines, is to
> have your .xsession write your DISPLAY variable to a file, and then in your
> login dot-files to check for the existence of that that file and use its

> One solution is to use the clients/xrsh on the R5 and R6 contrib tapes.  It
> includes xrsh, a script to start an X application on remote machine, and

>               [ Stuff about xrsh and xrlogind deleted ]

 So how about using .xsession (or /usr/openwin/lib/xdm/Xsession) to write
 the $DISPLAY variable to a file. Then when you log into another machine
 that shares the same home filesystem .... check for the existence of
 that file and read the $DISPLAY variable from it! If you are attempting
 to log into a machine that does not share the same filesystem you can read
 farther in the FAQ about how to either a) start a remote shell passing the
 $DISPLAY environment and/or b) use xrlogind to pack $TERM and $DISPLAY into
 $TERM ... use xrlogind to extract it on the remote machine, etc.

 I have used all of the above successfully.

 Hope that is enough to lead you to your final solution,

 jim carhart

--
 James A. Carhart                     | "how are we doing, Sirs?"
 Physics Dept., Georgetown University |                             - mst3k
 37th & O Streets, N.W.               | the views expressed here are
 Washington, D.C. 20057               | definitely not those of my employer

 
 
 

Setting the DISPLAY Environment variable

Post by Richard Leyto » Thu, 16 Nov 1995 04:00:00


In the spirit of usenet, and to save anybody else sending me e-mails (thanks to
those of you who did!), here is a synopsis of my findings.

There is a FAQ for X, which in section 36 explains how to transfer the
DISPLAY environment variable in a number of different ways. I opted
to take one of these suggestions, which was to write the X server
into a file in the .xinitrc file because the users home directory
is available on all machines through NFS.

X-Faq from: http://www.lib.ox.ac.uk/internet/news/faq/comp.windows.x.html

There were some very crafty scripts written by people to get the
machine from which somebody was logging in from, the disadvantage with this
approach though is that if anybody goes into one machine, alls ok, but
if they then log into another machine, the script points back to the
machine effectively in the middle, and if the user has done xhosts + they
might end up with unwanted windows...

set TTY_VAL=`tty`
set TTY=`echo $TTY_VAL | awk '{FS ="/"} {print $3"/"$4}'`
set YOU=`finger | grep $TTY`
setenv DISPLAY `echo $YOU | awk '{print $7}'`:0.0
unset TTY_VAL
unset YOU

Thanks to Kent Marfleet and Darrel Hankerson in particular for your
suggestions.

Regards,

Richard Leyton.

--
Richard Leyton, AMS Management Systems Deutschland GmbH,
              Am Seestern 1, 40547 Duesseldorf, Germany.

WWW: http://www.brookes.ac.uk/~e0190404/home.html

Opinions are my own, and not representative of AMS.

 
 
 

Setting the DISPLAY Environment variable

Post by Darrel Hankers » Thu, 16 Nov 1995 04:00:00


   How can I pass the DISPLAY environment variable when a user
   logs into another machine?
   [Usual "who am i" not completely acceptable for a number of reasons]

If I recall correctly, this is covered fairly well in the X faq (look
on http://www.earthlink.net/free/bigbee/webdocs/links.html).  There
are two basic answers that I received when I asked Auburn's
engineering sysadmins about this.

1. If you are willing/able to use .rhosts or hosts.equiv, then
xrsh/xrlogin (described in the faq) may be a solution. Many folks
think .rhosts is a bad idea.

2. Attach the DISPLAY to one of the variables which is passed thru the
rlogin (the faq suggests TERM) and parse on the other side. Given your
stmts about "who am i" and users, this may not be acceptable.

We have an additional snag: Our X-terminals will report the host on
a "who am i" type solution. Also, we cannot use hosts.equiv (we don't
own the other side). We may try using an "expect" script to manage
the DISPLAY from our side. This has the advantage of being transparent
to users, but it needs to be written carefully.

--

 
 
 

Setting the DISPLAY Environment variable

Post by Timothy E. Rabor » Tue, 21 Nov 1995 04:00:00



> A question I've been puzzling over for a while is:

> How can I pass the DISPLAY environment variable when a user
> logs into another machine?

> [snip snip snip]

> I've scoured the FAQ and other sources to no avail (or I'm going blind and
> have missed it), so maybe someone would care to enlighten me.

Check the fax for comp.windows.x (http://www.x.org/consortium/x_info.html)
I believe it has what you are looking for.  I remember reading this a while
back, so I can't tell you which # of the FAQ.  The method explained in the
FAQ depended on your using XDM to log in initially.

BTW:  you probably should have posted to comp.windows.x

===========================================================================

Computer Analyst/Systems Administrator   Voice:              (601) 688-3322
Scientific Systems Section               Fax:                (601) 688-7918
Lockheed Martin                          Stennis Space Center
http://www.lmco.com                      http://www.ssc.nasa.gov/
===========================================================================

 
 
 

1. Automatically Set DISPLAY Environment Variable after rlogin

Hi,

Maybe it's a brain lapse, but I seem to remember that there was a clever way
to have your X-server DISPLAY variable carried with you when you rlogin from
one machine to another.  I'm using TCSH as our default shell, so I can use
the REMOTEHOST variable for one hop.  Is there something special I can do if
I have two hops (i.e. rlogin into one machine and then into another after
that)?

Thanks!

TG

2. HP SureStore Tape Library and Sun

3. Error: $DISPLAY environment variable not set.

4. Solaris users limit

5. netcfg: TclError: no display name and no $display environment variable

6. Change MAC address without down interface

7. no display name and no $DISPLAY environment variable

8. Solaris 7 x86 driver for Advansys ASB-3940U2W SCSI ctrl?

9. Displaying environment variables dynamically in a Korn Shell Script

10. Display value of environment variable

11. Environment Variable - $DISPLAY

12. Telnet Session Default DISPLAY Environment Variable

13. What are the JDK DISPLAY environment variable