Operating System - HP-UX
1819804 Members
3289 Online
109607 Solutions
New Discussion юеВ

Automatically set DISPLAY Variable ?

 
Rene_17
Regular Advisor

Automatically set DISPLAY Variable ?

I used rlogin for remote login. Each time i could type in the display variable value.

With ssh i know how it works:

ssh -X user@host

Do anyone know how it works with rlogin ?

Rene
10 REPLIES 10
Simon Hargrave
Honored Contributor

Re: Automatically set DISPLAY Variable ?

Hi

You can add this to your .profile: -

export DISPLAY=`who -ma | awk '{print $8}'`:0
Pete Randall
Outstanding Contributor

Re: Automatically set DISPLAY Variable ?

Rene,

We avoid the problem entirely by using remsh:

remsh -n /usr/bin/X11/hpterm -display $DISPLAY -ls -title $1 -n $1 -s
b -sl 500 &


Pete

Pete
Rick Garland
Honored Contributor

Re: Automatically set DISPLAY Variable ?

I am using the who -um in .profile for the user.


export DISPLAY=`who -um | awk '{print $NF}'`:0
echo "DISPLAY is set for $DISPLAY"
Rene_17
Regular Advisor

Re: Automatically set DISPLAY Variable ?

I login with Exceed from a windows machine !
hostname: pc14-c803

When i log on an other server machine via the unix server the host name of the server is set to the display variable an not the variable from the windows machine !

How can i set a display variable on a remote machine like the display variable on the local machine ?

Regards,
Rene
Marcel Boogert_1
Trusted Contributor

Re: Automatically set DISPLAY Variable ?

Hi there,

Edit your .profile and add the following line:

export DISPLAY=$(/etc/ping $(who -muR | awk '{print $NF}') -n 1 | grep icmp | aw
k '{print $4}')0.0

MB.
Muthukumar_5
Honored Contributor

Re: Automatically set DISPLAY Variable ?

There is a problem when using who command with -R

-R is used to print hostname

When ever your IP-Address get's resolved then only hostname will be in the who -am output

Example:

-- /etc/hosts --
ip-address test.test.com test

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

If you login as ,

telent test
login/passwd

check the who -am output now,

it will be as test.test.com not with ip-address.

Display value will get problem when using xterm there.

So try to change as,

IP=$(getip `who -am | awk '{ print $8 }'`)
DISPLAY=$(echo $IP:0)
export $DISPLAY

on .profile file.

Regards
Muthu
Easy to suggest when don't know about the problem!
Marcel Boogert_1
Trusted Contributor

Re: Automatically set DISPLAY Variable ?

Muthu,

Thats's why the ping command is involved.

MB.
Rene_17
Regular Advisor

Re: Automatically set DISPLAY Variable ?

Setting the display variable works, but the X11Forwarding doesn├В┬┤t work !

When you lo in you were asked typing in Display Variable ! What system script is that ?

Regards,
re
Muthukumar_5
Honored Contributor

Re: Automatically set DISPLAY Variable ?

We have to set DISPLAY variable so that we can start the display on remote machine's shell.

The discussion between me / marcel are based who command. We are getting IP-Address over from there. when ever it's IP-Address resolved then only hostname will come.

Problem is, if we set DISPLAY with hostname then x-windows won't run. It will make problem. So that we can use getip or ping to get ip-address

Remote shell testing.

machine1 --> machine2

I hope r* command setting for rhosts file are made.

check as,

machine 1# remsh machine2 hostname
machine2

So r* is working fine.

Test:

#!/usr/bin/ksh
# remote.ksh
# $1 - hostname
# $2 - user
if [[ $# -ne 2 ]]
then
echo "Usage: remote.ksh "
exit 1
fi

# Display variable
IP=$(getip `who -am | awk '{ print $8 }'`)
DISPLAY=$(echo $IP:0)
export $DISPLAY

# Remote x11 testing
remsh $1 -l $2 -n "/usr/dt/bin/hpterm -display $DISPLAY"

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

It will start xwindows now.

You can start it parrelel as
remsh $1 -l $2 -n "/usr/dt/bin/hpterm -display $DISPLAY" &
remsh $1 -l $2 -n "/usr/dt/bin/hpterm -display $DISPLAY" &

Regards
Muthu
Easy to suggest when don't know about the problem!
Rick Garland
Honored Contributor

Re: Automatically set DISPLAY Variable ?

You don't need to set the DISPLAY on the remote machine that you are connecting to. You want the DISPLAY to come back to you, to be on the local machine you are working on, not the remote server.

On the remote server that you connect to you want to make sure you have done `xhost +` and the response from the remote server would be
"access control disabled, clients can connect from any host"

This function works from Exceed or any other X emulation application. The access control must be disabled to have X11 traffic forwarded