Operating System - HP-UX
1832762 Members
2957 Online
110045 Solutions
New Discussion

Re: telnet/DISPLAY: HPUX vs Solaris

 
SOLVED
Go to solution
Tom Dawson
Regular Advisor

telnet/DISPLAY: HPUX vs Solaris

Hi,

I have a Linux workstation that I use to connect to both HPUX 11.11 and Solaris 8 servers. When I telnet to the Solaris servers, the DISPLAY environment variable is "automatically" set, pointing back to my workstation. When I telnet to the HPUX servers, the DISPLAY environment varialbe is not set.

Is there a way to configure telnetd on HPUX so that the DISPLAY environment variable gets set?

( Yes, I know I SHOULD be using ssh )

Thanks,
Tom
8 REPLIES 8
Robert-Jan Goossens
Honored Contributor

Re: telnet/DISPLAY: HPUX vs Solaris

Hi Tom,

Edit you .profile

-----

# -- Do trick to set the display in case of remote login
PTS=`who am i |awk '{ print $2 }'`
#HOST=`who | grep ${PTS}' ' | cut -c38- | sed 's/(\(.*\)[:][0][.][0])/\1/'`

HOST=`who | grep ${PTS} | awk '{print $6}' | sed -e 's/[()]//g'`
if [ "$HOST" != "" ] && [ "$HOST" != ":0" ] && [ "$HOST" != ":0.0" ];
then
echo " +--<<"
echo " | Remote login detected, setting DISPLAY to $HOST:0.0"
echo " +-->>"
export DISPLAY=$HOST:0.0
fi

set -o vi

-------

Robert-Jan.
Zeev Schultz
Honored Contributor

Re: telnet/DISPLAY: HPUX vs Solaris

In the user's ~/.profile if using ksh (check in /etc/password).
In ~/.login I think in csh.
export DISPLAY=X.X.X.X:0.0
setenv DISPLAY X.X.X.X:0.0

Zeev
So computers don't think yet. At least not chess computers. - Seymour Cray
Elena Leontieva
Esteemed Contributor

Re: telnet/DISPLAY: HPUX vs Solaris

Tom,

I found this rather old document: A4667710 (1997):

The following scripts allow the DISPLAY variable to be set
regardless of rlogin or telnet.

The first script can be melded into the .profile file.

---------------------------1st script---------------------------------
DISPLAY=`/bin/who -mR | sed 's/.*(\([a-z0-9]*\).*/\1/'`:0
export DISPLAY
----------------------------------------------------------------------

The second script is a separate script with comments telling
what to put in the .profile. Both scripts will work.

---------------------------2nd script---------------------------------
#!/bin/ksh
# Put the following at the top of your $HOME/.profile
#echo $TERM | grep -q =
#if [ $? = 0 ]
# then
# DISPLAY=${TERM#*=}
# export DISPLAY
# TERM=${TERM%=*}
# echo "DISPLAY=$DISPLAY"
# echo "TERM=$TERM"
#fi
#
#
# Invoke as follows:
# xlogin
#
export TERM=$TERM=$DISPLAY
rlogin $1
-----------------------------------------------
Tom Dawson
Regular Advisor

Re: telnet/DISPLAY: HPUX vs Solaris

All,

Thanks for the replies!

It will take me a day or two to implement and test these options. I'll be back with points and what worked/didn't work after that.

Thanks again,
Tom
Tom Dawson
Regular Advisor

Re: telnet/DISPLAY: HPUX vs Solaris

Robert-Jan,

Thanks, but the " PTS=`who am i |awk '{ print $2 }'` " command set PTS to the pseudo-terminal "pst/nn" on my server. And then the HOST variable ended up empty with:
HOST=`who | grep ${PTS} | awk '{print $6}' | sed -e 's/[()]//g'`
becasuse there was no $6 field from the who comamnd. I'm using HP-UX 11.11. Maybe 'who' is working different for me? Is the LOCALE different for a default install in the U.S. versus the Netherlands?

Zeev,

Thanks, but I was trying to avoid arbitrarily setting the DISPLAY variable. If I telneted into the target server from someplace other than my workstation, I wouldn't want the DISPLAY variable pointing to my workstation.

Elena,

Yours got me to the solution but there were some problems. The
DISPLAY=`/bin/who -mR | sed 's/.*(\([a-z0-9]*\).*/\1/'`:0
command set DISPLAY to "first octet:0". It truncated the 2nd, 3rd, and 4th octets of the IP address. But I just replaced it with this
DISPLAY=$(who -mR | cut -f2 -d"(" | cut -f1 -d")")
DISPLAY=${DISPLAY}:0.0
and I was cooking.

I always forget that there are other options to the simple commands like "who" that I use everyday.

Again, thanks to all.
Tom
Caesar_3
Esteemed Contributor

Re: telnet/DISPLAY: HPUX vs Solaris

Hello!

You have the option to set the DISPLAY in
enviroment files but you also have options
in ssh & X that made automaticly x-forwarding
that if you made ssh connection and not set
dispaly it go automaticly to the machine that
you start the ssh conection from.

Check the docs of ssh for enable this.

Caesar
Elena Leontieva
Esteemed Contributor

Re: telnet/DISPLAY: HPUX vs Solaris

Tom,

Sorry, that it appeared not working. You may also want to simplify a little, like this:
hpd320te(root):/> DISPLAY=`who -mR |cut -f2 -d"("|cut -f1 -d")"`:0.0
hpd320te(root):/> echo $DISPLAY
10.5.13.23:0.0

Elena.
Bill Hassell
Honored Contributor
Solution

Re: telnet/DISPLAY: HPUX vs Solaris

This is the simplest method to set DISPLAY:

export DISPLAY=$(/usr/bin/who -muR | awk '{print $NF}'):0.0

This works well in case who changes the number of parameters ($NF is always the last one). Note that some admins will use the TERM variable to propagate the local machine's name. That's because the telnet protocol will carry TERM through to the server...which is OK unless the window you are starting is a text window like xterm, dtterm, hpterm, etc. The TERM value must match the actual model of terminal being used and a DISPLAY value won't work. That's why /etc/profile or .profile should always run ttytype during login (and ignore the current value of $TERM) as in:

eval $(ttytyps -s)

This will query the terminal directly rather than using $TERM as is.


Bill Hassell, sysadmin