Link to home
Start Free TrialLog in
Avatar of cplager
cplager

asked on

exporting DISPLAY

       I am trying to figure out how to set it up so that when open a new shell with xterm, it sets DISPLAY on the new shell the same as it was onthe old shell (NOT to the computer where the old shell is).  
        If it were just rlogin and not xterm I could just modify TERM, but xterm sets that variable to 'xterm' automatically.  Are there any other variables that are passed?  Is there anyway to read the title bar of an
xterm window (just set it equal to the display)?  Any other ideas?
Avatar of ozo
ozo
Flag of United States of America image

Are you saying DISPLAY is not being passed to the new shell?
I'm a bit confused. Is you problem DISPLAY in a new xterm, or after rlogin to an other host?

If you just miss DISPLAY, set it in your shell's system profile
(/etc/csh.login, /etc/profile, many more ... depends on your OS
*and* your shell).
If you need to set DISPLAY after rlogin to the host where you
typed rlogin, you need a more sophisticated solution (IRIX for
example passes REMOTEHOST to the shell); stacked rlogins will be
a problem too.

> Is there anyway to read the title bar of an xterm ...
Not easy, means from within the shell.
To set the title you may use:

   echo -n "^[]0;\!*^G"

NOTE that  ^[  is ESC (0x1b), and  ^G  is  BEL  (0x07).



Avatar of cplager
cplager

ASKER

Let me try and clarify the problem.  I login from my computer at come home.org.  I then run an xterm on one.org with DISPLAY set to home.org.  When I run a new xterm from one.org to two.org, I do not want my DISPLAY set to one.org, but rather home.org (as it is set one one.org).  How can I set this up automatically?
Not easy. That's what I meant by "more sophisticated".
Your problem is similar to nested rlogins. If there are different
operating systems, things get complicated.
I can give you a solution for primary rlogin, but for all follow-
ing nested ones I just have hints.

You must do somthing like:
   tty      tells you on which device your shell (xterm) is
   ps ax    search for lines which belong to this tty
            get the PPID of the shell of this tty
            then get tty of PPID
   w        search line with PPID's tty, it contains the name
            of the host where it is from
            set DISPLAY to that host

I've seen a posting in e-e, where an expert sad that this all
could be done via the files utmp (or wtmp?), may be with the last
command, see (I'm not shure this works nested):
   /https://www.experts-exchange.com/topics/bin/ShowQ?qid=8630005776

Feel free to ask me for more help, good luck.
           
ASKER CERTIFIED SOLUTION
Avatar of df020797
df020797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here are a few ideas.
1) if you start a new xterm from your existing xterm, it will
have the DISPLAY set just fine.
2) If you use ssh, your display will be set automatically
(even the first time) - requires installing ssh on home.org and one.org
3) if you have passwordless login enabled through rsh/rhosts, you can use a program called xrsh - ftp.x.org:contrib/utilities/xrsh-5.8.shar.gz
If you're using telnet, you can create a ~/.telnetrc containing:
 hostname environ define DISPLAY $DISPLAY
 hostname environ export DISPLAY
Note that you may need to re-create this file every time you log on, as the value of $DISPLAY must be hardcoded.

If you're using rlogin/rsh, you can carry the variables across in other variables which you know will get sent. So, you create a rlogin wrapper as such:
 #!/bin/sh
 # rlogin wrapper to send extra variables in USER
 # Grant Kaufmann 1997 grant@intekom.com

 # SETUP vars. site specific
 # location of rlogin
 RLOGIN=/usr/bsd/rlogin
 # command which prints out env names. might be "env" or "export"
 PRINTENV=printenv
 # where is egrep
 EGREP=/usr/bin/egrep
 # whats going with us. egrep format
 COPY_VARS="^TERM=|^DISPLAY=|^LINES="

 NEWENV=`$PRINTENV | $EGREP "$COPY_VARS"`

 # redefine $USER cos its going anyway. You could use TERM or something
 USER="$RLOGIN_ENV" $RLOGIN $*

And then in the receiving host:

 # Grant Kaufmann 1997 grant@intekom.com
 # put this in your startup file on the dest machine
 # set variables fromm a rlogin session
 # using korn/bourne again/etc, make SETENV="export". Otherwise "setenv"
 SETENV=export
 NEWVARS=`echo $USER |/bin/sed -n 's/\([^=]*\)=\([^ ]*\)/ $SETENV \1 "\2";/gp' `
 eval $EVARS