It is currently Fri, 18 Apr 2014 09:56:30 GMT



 
Author Message
 What's thr trick for auto setting of DISPLAY with remote logins?

I can't remember what the accepted/recommended method for doing this
is.  I use Korn shell.

Thanks,
--

############################################################
#  John Vella            #  Job  : Software Development    #
##########################  Email: john_ve...@mentorg.com  #
#  Mentor Graphics Corp. #  Phone: (503) 685 - 7000 x1170  #
#  Wilsonville, OR       #  Fax  : (503) 685 - 1461        #
############################################################



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

I don't know either, but I hacked something like this:

MYID=`who am i|awk '{ print $1 }'
DISPLAY=finger|grep $MYID|awk '{ print $9 }';export DISPLAY

Two warnings: the finger command, in some versions of unix, will not
print the login terminal name.  Also, if a user logins using two
sessions from two different client terminals, only the first one will
be set to DISPLAY.

Chris
(return address munged to avoid spammers, remove XXX for the real one)



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

Since the TERM variable is promoted by rlogin, the basic idea is to
"tunnel" the setting of the DISPLAY variable through TERM.

On the hosts you are logging into, add this to the front of your
.profile before the invokation of any commands that need to know about
the terminal type (e.g. tput):

  #
  # kludge to propagate DISPLAY
  #   works for both ksh and bash
  #
  case "$TERM" in
    *\|*)
      export DISPLAY=${TERM#*\|}
      TERM=${TERM%%\|*}
      ;;
  esac

That is, if there's a '|' character in the TERM variable, assume this
marks combined TERM & DISPLAY information, split it up, and set the
respective variables appropriately. '|' is used by both termcap and
terminfo to separate terminal names, so it's safe to assume that it
won't appear as part of a terminal name.

If there are any commands in /etc/profile that already require a proper
TERM setting, you are out of luck.

On the host you are logging in from, use

  TERM="$TERM|$DISPLAY" rlogin host

Obviously that's a good candidate for an alias like

  alias drlogin='TERM="$TERM|$DISPLAY" rlogin '

or even a shell script, if, like me, you're suffering from the problem
of display names lacking domain information and the target hosts being
in a different domain:

  #!/bin/ksh
  #
  # kludge to propagate DISPLAY variable
  #
  # 1997-04-09  naddy

  if [[ -n $DISPLAY ]]; then
    # fully qualify display name
    DISPLAY_HOST=${DISPLAY%%:*}
    DISPLAY_NUM=${DISPLAY#*:}
    DISPLAY_HOST=$(nslookup "${DISPLAY_HOST}" | \
      sed -n 's/^Name:[         ]*\(.*\)/\1/p')
    DISPLAY="$DISPLAY_HOST:$DISPLAY_NUM"
    # append to TERM
    TERM="$TERM|$DISPLAY"
  fi
  exec rlogin "$@"

  #EOF#

--
Christian 'naddy' Weisgerber                  na...@mips.rhein-neckar.de
  See another pointless homepage at <URL:http://home.pages.de/~naddy/>.



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

: I can't remember what the accepted/recommended method for doing this
: is.  I use Korn shell.

I use csh, but I believe this should work with ksh like this:

local machine:

rlogin(){
  case "$DISPLAY" in
    :[0-9]*) DISPLAY="`hostname`$DISPLAY" ;;
  esac
  TERM="${TERM}^$DISPLAY" rlogin "$@"

==============================
remote machine .profile:

eval `echo $TERM | sed -e 's/^/export TERM=/' -e 's/\^/ DISPLAY=/'`

==============================
Then you can "rlogin your_host_name" in your local machine.

I am not sure about ksh, but it seems to work under bash.

Michael



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

On 24 Apr 1997 05:52:14 GMT, jve...@mentorg.com (John Vella) wrote:

Put this script somewhere that is in every path (for example,
/usr/local/bin/get_host):

#!/bin/sh
#
xtty=`tty | cut -c6-15`
h2=`who | grep $xtty | tr -d '()'`
xc=`echo $h2 | wc -w`
if [ $xc = 6 ]; then
echo $h2 | awk '{ print $6 }'
else
hostname
fi          

In your .profile :

DISPLAY=`/usr/local/bin/get_host`
export DISPLAY

This works for us on Solaris 2.[345]. Doesn't work when you telnet
into one box, then rlogin to another. YMMV.
********************************************************
** Dave Annis         | With age comes wisdom, if you **
** Sheboygan, WI      |   stay awake along the way!   **
********************************************************



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

: I can't remember what the accepted/recommended method for doing this
: is.  I use Korn shell.

: Thanks,
: --

: ############################################################
: #  John Vella            #  Job  : Software Development    #
: ##########################  Email: john_ve...@mentorg.com  #
: #  Mentor Graphics Corp. #  Phone: (503) 685 - 7000 x1170  #
: #  Wilsonville, OR       #  Fax  : (503) 685 - 1461        #
: ############################################################

rlogin passes the TERM variable.  You can stuff whatever you need
into that.  Thus

alias rlogin="TERM=\"TERM=$TERM DISPLAY=$DISPLAY\" rlogin"

Then,  in your .profile

case $TERM in
   *=*) eval export $TERM;;
esac

The following also work:

case $TERM in *=*) eval export $TERM;;esac

and

[[ "$TERM" = *=* ]] && eval export $TERM

--
Dan Mercer
Reply To:  damer...@mmm.com

Opinions expressed herein are my own and may not represent those of my employer.



 Mon, 11 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

Could of course do it the easy way!  Pick up xrsh.5.8.shar.gz

from: ftp://ftp.cdrom.com/pub/X11/contrib/utilities

see: ftp://ftp/cdrom.com/pub/X11/contrib/utilities/xrsh.README
for details prior to downloading

Also includes xrlogin.  No more need to set $DISPLAY after login.

--
Daniel James
--
"Yeah man, I tell ya what, man.....That dang ol'  Internet,
man.....You just go on there  and point  and click.....Talk
about W-W-dot-W-com....An'  lotsa  nekkid  chicks on there,
man... Click... Click... Click... Click.. Click.. It's real
easy man."-- Boomhauer on the Internet,  _King of the Hill_



 Tue, 12 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

| I can't remember what the accepted/recommended method for doing this
| is.  I use Korn shell.

There are several hacks, as you have seen.

From one point of view, the right way is to have the connection software
transfer this environment variable through its own protocol.  This is
already possible with the telnet protocol (using the XDISPLOC parameter.)

Some vendors supply telnet and telnetd with this option already supported.
DEC has done that for years, in what they used to call OSF/1 and now call
Digital UNIX.  NCD's builtin telnet client supports it.  If your software
doesn't support it, you have cause for complaint.

If you want to add this support on top of a vendor base that doesn't
have it, I'd suggest that you get Kerberos 5 from MIT.  Their telnet
and telnetd are drop in replacements, supporting but not requiring
Kerberos 5 authentication, and they support XDISPLOC and thus DISPLAY.
See http://web.mit.edu/kerberos/www/krb5-1.0/announce.html.  

If you want to do it yourself, you need source for telnet, telnetd
and login.  I never looked at rlogin, but I assume it would be roughly
similar, with perhaps the disadvantage that it's not already there in
the more informal rlogin protocol and thus wouldn't interoperate with
anyone else.  MIT's krb5 rlogin doesn't pass DISPLAY.

   Donn Cave, University Computing Services, University of Washington
   d...@u.washington.edu



 Tue, 12 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

What about auto setting of DISPLAY when doing an su - ?

I don't think su even propagates TERM. Any ideas?
:



 Tue, 12 Oct 1999 03:00:00 GMT   
 What's thr trick for auto setting of DISPLAY with remote logins?

The above does not work in many cases. If you rlogin from machine A to machine
B and then again to machine C, machine C would set the DISPLAY to machine B
rather than to machine A. Secondly, the above does not have ':0' following
the call to hostname. Thirdly the above does not work when many people using
similar ttys - e.g. someone using /dev/pts/1 and /dev/pts/11. Fourthly, the
above does not work when one works on a XTerminal and does an rlogin to
another machine.

Here is what I use - this is primarily for setting the DISPLAY automatically
upon rlogin. To set the display in the local machine, one can simply use
DISPLAY=`hostname`:0 ; export DISPLAY. (I use bash and so my scripts are
Bourne-shell compatible scripts).

I use the following in my .bashrc:

        function rlogin ()
        {
                if [ "$TERM" = "xterm" -a  "x$DISPLAY" != "x" ] ;then
                        xhost + $1 > /dev/null
                        TERM="${DISPLAY}#${TERM}"
                        export TERM
                fi

                command rlogin "$@"
        }

        echo $TERM | grep "#" >& /dev/null
        if [ $? -eq 0 ]
        then
            export DISPLAY=`echo $TERM | awk -F'#' '{print $1}'`
            export TERM=`echo $TERM | awk -F'#' '{print $2}'`
        fi

Explanation:

Suppose one does an rlogin from machine A (on which the DISPLAY is already set)
to machine B. The environment variable TERM is copied over to machine B by
the system. The above scripts exploit this fact to copy over the DISPLAY.
The function 'rlogin' copies both the current TERM as well as the DISPLAY into
TERM before calling rlogin. On machine B, the .bashrc file checks for this
fact (the grep for '#' in TERM). If this succeeds, the TERM and DISPLAY are
individually extracted from the TERM variable that was passed on by rlogin.

The above method will work while using rlogin any number of times across any
number of machines provided the display was set correctly in the first machine
(provided of course that each machine has the ability to change the xhost
capabilities).

--
Mohit Aron                              email:  a...@cs.rice.edu
Department of Computer Science          smail:  8020 Braesmain Drive #1801  
Rice University                                 Houston, TX-77025    
phone: (713) 527-8750 (x2265)                   phone:  (713) 662-0501        



 Thu, 14 Oct 1999 03:00:00 GMT   
 
   [ 10 post ] 

Similar Threads

1. Remote XWindows and auto display export.

2. is thr anything like remote command??

3. setting DISPLAY var on multihop logins.

4. help setting up getty for remote modem logins ans sliplogin

5. Setting Linux for Remote Logins

6. Please advise: Auto Setting of DISPLAY env

7. DISPLAY variable auto-set

8. What's the trick to set up dual boot for Linux and Win2k


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software