[comp.windows.x] X-windows DISPLAY environment variable

gerald@ge1cbx.UUCP (Gerald Aden) (07/03/90)

I am trying to figure out a way to automatically resolve
and set the DISPLAY environment variable when someone logs  
into one of our systems from X-terminals using telnet and rlogin.
I know that there must be some way to resolve the IP name or address
of someone who is logging into a system. Can anyone think of a way to 
do this such that it could be incorporated a part of the login process
(i.e. put in .login or .profile). 


-- 
Quotron Systems Inc.	          | Phone: (213)302-4254 FAX: (213)302-4499
Dept. 36240                       | uucp: ...!uunet!janus!ge1cbx!gerald
12731 West Jefferson Blvd.        |
Los Angeles, CA 90066             |

rajeshg@diamond.tamu.edu (Rajesh Godbole) (07/04/90)

try this:


alias set_display 'set t=`finger -s $USER`;setenv DISPLAY `echo $t[13]`:0.0'
set q=`finger -s $USER | grep co`
if ($q == "") eval set_display >>& /dev/null

i've put this in my login file, it sets the DISPLAY variable to 
`logged-on-from`:0.0 if you're not logged on on the console of your machine.  




Rajesh Godbole,				|  preferred: rajeshg@diamond.tamu.edu
Department of Electrical Engineering.	|  otherwise: godbole@eemips.tamu.edu
Texas A&M University, College Station.	|  (409) 696-9528.
------------------------------------------------------------------------------

rajeshg@diamond.tamu.edu (Rajesh Godbole) (07/04/90)

In article <331@ge1cbx.UUCP>, gerald@ge1cbx.UUCP (Gerald Aden) writes:
|> I am trying to figure out a way to automatically resolve
|> and set the DISPLAY environment variable when someone logs  
|> into one of our systems from X-terminals using telnet and rlogin.
|> I know that there must be some way to resolve the IP name or address
|> of someone who is logging into a system. Can anyone think of a way to 
|> do this such that it could be incorporated a part of the login process
|> (i.e. put in .login or .profile). 
|> 


try this:

alias set_display 'set t=`finger -s $USER`;setenv DISPLAY `echo $t[13]`:0.0'
set q=`finger -s $USER | grep co`
if ($q == "") eval set_display >>& /dev/null

i put this in my login file, it sets the DISPLAY variable to
`logged-on-from`:0.0
if you're not logged on to the console of your machine.  


Rajesh Godbole,				|  preferred: rajeshg@diamond.tamu.edu
Department of Electrical Engineering.	|  otherwise: godbole@eemips.tamu.edu
Texas A&M University, College Station.	|  (409) 696-9528.
------------------------------------------------------------------------------

matt@bacchus.esa.oz (Matthew Atterbury) (07/04/90)

In article <331@ge1cbx.UUCP> gerald@ge1cbx.UUCP (Gerald Aden) writes:
>I am trying to figure out a way to automatically resolve
>and set the DISPLAY environment variable when someone logs  

Dunno about your system, or TELNET, but a `who` gives:

matt                 ttyp3       Jul  4 09:14   (thomas:0.0)
henry                display     Jul  4 07:37

The (thomas:0.0) says that I'm rlogin'd from thomas. On my 'own' system,
it doesn't list me coz of xdm not updating the /etc/utmp file (rickin' nickin'
rackin' %$%!$%). Use `tty` to work out which line in `who` "you" are (if any),
then see if `who` tells you the host or display name & extract it for setting
DISPLAY (this doesn't work perfectly for rlogins from the second or subsequent
screens, though this setup is not common?). Use ":0" if no host given.
    I leave the shell script for this to the reader. :-)
-- 
-------------------------------------------------------------------------------
Matt Atterbury [matt@bacchus.esa.oz.au]   Expert Solutions Australia, Melbourne
UUCP: ...!uunet!munnari!matt@bacchus.esa.oz.au            "klaatu barada nikto"
ARPA: matt%bacchus.esa.oz.AU@uunet.UU.NET  "life? don't talk to me about life!"

earle@POSEUR.JPL.NASA.GOV (Greg Earle - Sun JPL on-site Software Support) (07/05/90)

In xpert/comp.windows.x article <26900123@m.cs.uiuc.edu> Alan Carroll writes:
>Re: Setting DISPLAY across telnet/rlogin
>
>Both telnet and rlogin preserve the TERM variable (at least in my experience -
>maybe it fails in some locations). You can use this fact to pass additional
>information along by setting TERM to be something like "real_term@display",
>and then having the .login / .profile pick look at TERM, and if it's of this
>form, extract the information, set DISPLAY, and fix TERM to be just
>"real_term" again. rlogin and telnet can then be aliased/functioned to set
>TERM appropriately just before executing the real binary.

If you can find Dave Borman's recent posting to TCP-IP/comp.protocols.tcp-ip,
the new release of the pre-4.4BSD telnet/telnetd client and server now
contains support for negotiation of the XDISPLOC telnet option, as long as
the `login' program on the telnetd server end supports the `-p' flag to
preserve the environment variables.  I suspect that as this version is
widely distributed and implemented, it will make this issue a moot point.
(I presume that setting DISPLAY from XDISPLOC will be rather straightforward)

--


-- 
	Greg Earle			| "This is Kraft.  It uses a blue box.
	Sun Microsystems, Inc.		|  This is Stouffer's.  It uses red.
	earle@poseur.JPL.NASA.GOV	|  The choice is yours."
	earle@Sun.COM			|  Pretty damn convincing argument, eh?

peter_colby@viewlogic.COM (07/05/90)

I am trying to figure out a way to automatically resolve
and set the DISPLAY environment variable when someone logs  
into one of our systems from X-terminals using telnet and rlogin.

------------------------

	I know of one way using rsh and a program from gnuemacs
(18.55) called env.

" rsh <system> /usr/local/emacs/etc/env DISPLAY=${DISPLAY} xterm &"

	On our systems, the emacs libraries (lisp, etc,info) are
kept in /usr/local/emacs. The documentation for env says that env
will set the environment as specified (DISPLAY in this case) and
then exec the specified command. The prolog in env.c has the only
documentation available as the gnuemacs developers seem to consider
env internal support only.
	This won't help telnet, I'm sorry.
	Peter C

--
peter@viewlogic.com