Operating System - HP-UX
1850398 Members
2267 Online
104054 Solutions
New Discussion

Bet you can't solve my $DISPLAY problem

 
Gary Cooper_1
Esteemed Contributor

Bet you can't solve my $DISPLAY problem

Machine1: HP-UX 10.20
Machine2: HP-UX 10.20
Machine3: HP-UX 10.20
(User runs ksh)
PC1: Running XVision X-Terminal Emulator

Here's what I want to be able to do:
1) Log in to Machine1 at the console.
(DISPLAY=Machine1:0.0)
2) Log in to Machine1 at the console.
rlogin to Machine2
(DISPLAY=Machine1:0.0)
3) Log in to Machine1 at the console.
rlogin to Machine2
rlogin to Machine3
(DISPLAY=Machine1:0.0)
4) Log in to Machine1 from PC1.
(DISPLAY=PC1:0.0)
5) Log in to Machine1 from PC1.
rlogin to Machine2
(DISPLAY=PC1:0.0)
Note that the user may have more that one session running on any of the Unix machines e.g. 4) followed by 1) or vice versa.

I'd be very grateful to anyone that can come up with a solution to this problem.
27 REPLIES 27
harry d brown jr
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem


What's the issue?

after logging into a machine do this:

export DISPLAY=display:0.0

live free or die
harry
Live Free or Die
Jean-Luc Oudart
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

There is a trick !

when you rlogin to a machine you pass the TERM variable.
the "trick" consists in modiying the TERM variable before the rlogin , then when you run your /etc/profile on the target machine you analyse your TERM variable (for specific format), reformat your TERM variable and your DISPLAY variable.

e.g
TERM=vt220
before your rlogin
TERM=vt220:$DISPLAY

in your /etc/profile
check for such TERM variable : and rebuild both variable as they should be.

Jean-Luc
fiat lux
harry d brown jr
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

How about, instead of rlogin'ing using remsh?

remsh machineX /usr/bin/X11/xterm -sl 2000 -ls -sb -cr Wheat -T \`hostname\` -bg MidnightBlue -fg Wheat -fn 7x13 -fb 7x13B -display $DISPLAY &

live free or die
harry
Live Free or Die
Pete Randall
Outstanding Contributor

Re: Bet you can't solve my $DISPLAY problem

Gary,

I'm not sure I understood where your problem lies, but if you are using rlogin, you can try this:

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

where $1 is the name of the machine you want to go to.

HTH,
Pete

Pete
Ravi_8
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Hi,

i am confused with ur problem.

However from my workstation(PC1)
login to machine1
#export DISPLAY=PC1:0.0

works fine
never give up
Shannon Petry
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

I think you want to automate the setting of the DISPLAY variable depending on what client your using?
If so, you cant really do this, but can make separate ID's.
I.E.
user1
echo "DISPLAY=machine1:0.0 ; export DISPLAY" >>~user1/.profile
echo "setenv DISPLAY machine1:0.0" >>~user1/.cshrc

user2
echo "DISPLAY=pc1:0.0 ; export DISPLAY" >>~user2/.profile
echo "setenv DISPLAY pc1:0.0" >>~user2/.cshrc

Now as long as home directories are shared across the network, just login as user1 or user2. user1 would have the console as the display host, user2 would have the pc.
If home directories are not accross the network, you will have to add the lines above to all of their home dirs.

Regards,
Shannon
Microsoft. When do you want a virus today?
MANOJ SRIVASTAVA
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Hi Gary


alternatively for setting it for any user anywhere you can do like this

A=`who -T| grep user name | awk'{print $9}'`
export DISPLAY=$A:0.0

this will export the display to whichever machine you log in


Manoj Srivastava
Shannon Petry
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Minoj, I thought of this too, but he said users have multiple sessions on multiple machines. The who command wont work past the first login in that case.

Shannon
Microsoft. When do you want a virus today?
harry d brown jr
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Manoj,

how would it work when I login to a machine called vpart3 then rlogin to a machine called vpart6:

# who -T
root + console Aug 15 09:20 old 2184 system console
root - ttyp1 Aug 19 07:07 old 21189 10.2.181.64:0.0
root - ttyp2 Aug 21 10:03 0:13 19916 10.2.181.64:0.0
root - pts/0 Aug 21 10:17 . 20104 vpart3.paychex.com
# whoami
root
# tty
/dev/pts/0
# hostname
vpart6
#

4 users with the same name

live free or die
harry
Live Free or Die
Ron Cornwell
Trusted Contributor

Re: Bet you can't solve my $DISPLAY problem

Add the following lines to the .profile of any system that you would like to log and have your display automatically exported:

DEVICE=`tty | cut -d / -f3-4`
DISPLAY=`who -HT | grep $DEVICE | awk '{print $9}'`
export DISPLAY
MANOJ SRIVASTAVA
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Sorry Guys I see what yuo aer saying no coffee syndrome.


Manoj Srivastava
Gary Cooper_1
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

Thanks for the huge response!
Firstly, I do want to automate the process by putting the variable setup in .profile or something as some of my users don't have access to a shell prompt.

Also, the bit that is being forgotten is where I use my X-Terminal emulator and the DISPLAY variable is set to pc1:0.0, so I can't run remsh to get to my HP-UX box.

I guess looking at the problem closer, I could probably simplify it - the real problem at the moment is my users that don't have access to the shell prompt and who consequently don't do a rlogin to Machine2 or Machine3.

They fall into either scenario 1) or scenario 4) but could have both sessions active at the same time.

Hope this clarifies the problem somewhat.

Thanks again guys,

Gary
Wodisch_1
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Hi,

what do you refer to with "log in from PC1" - which protocol: TELNET, RLOGIN, RSHELL, XDMCP, SSH???

Well, as long as your PC1's hostname appears as the comment on the output of "who am I -u" it should be fairly easy: put these lines into that user's "$HOME/.shrc" (and if you do not have one, create it, and point $ENV to it from that user's "$HOME/.profile"):

if [ -t 0 ]
then # interactive
set +u
who am i -u | read user tty month day time idle pid comment
case "$comment" in
*:*) display="$comment" ;; # already X11
*.*) display="$comment:0" ;; # FQDN, do X11
PC1) display="$comment:0" ;; # from PC1, do X11
*) unset display ;; # no FQDN, no X11
esac
if [ -s "$display" ]
then export DISPLAY=${DISPLAY:-$display}
else export DISPLAY=PC1:0.0 # default
fi
fi


HTH,
Wodisch
Gregory Fruth
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

Sometimes you can get the value of DISPLAY
out of the variable REMOTEHOST. Otherwise,
you have to use one of the tricks mentioned by
the other posters.

At my installation we use a script I wrote
called magic_display (attached) which uses
"rusers" to get the value of DISPLAY.
Unfortunately "rusers" will have the same
limitation as "who -T" re: multiple logins.

The script is called from the .login file:

# Automagically set display
if (! $?DISPLAY) then
echo "Trying to determine your DISPLAY (Hit to abort)..."
if ($?REMOTEHOST) then
set DEFAULT_DISPLAY="$REMOTEHOST":0
else
which magic_display >& /dev/null
if ($status == 0) then
set DEFAULT_DISPLAY=`magic_display`
else
set DEFAULT_DISPLAY=none
endif
endif
echo "DISPLAY = ($DEFAULT_DISPLAY) \c"
setenv DISPLAY "$<"
if ("$DISPLAY" == "") setenv DISPLAY $DEFAULT_DISPLAY
if ("$DISPLAY" == "none") unsetenv DISPLAY
if ($?DISPLAY) then
echo "DISPLAY is set to $DISPLAY"
else
echo "DISPLAY is not set"
endif
unset DEFAULT_DISPLAY
endif
Kelli Ward
Trusted Contributor

Re: Bet you can't solve my $DISPLAY problem

HI Gary,
See if this helps.
on machine 1 be sure you either
xhost + (to disable access list to all hosts)
Or xhost + (each system name to add them all)
on all Unix boxes
export DISPLAY=machine1:0.0 (like Harry mentioned)
Hopefully you can now open GUI's for each UNIX box on machine1.

I have never used XVision, but if it is anything like Reflection X be sure:
XDMCP is set to broadcast (or direct with the appropriate IP_addres set)
You have the proper entries in your equivalent of C:\winnt\system32\drivers\etc\hosts and C:\reflect\user\xhost

and that TCP is set for the system IP_address or auto detect

(Again these are assumably different for XVision, but should give you settings to look for.)

Good luck,
Kel
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!
Andrew Cowan
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Depending on your terminal emulator, some products, eg. Exceed can launch an Xterminal etc, and use a macro (%H which refers to your hostname), and automatically solve the problem for you. SSH also does this.
Animesh Chakraborty
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

I Think you need to concentrate on xhost+ command.
Do a search using key word "xhost" you will get solution.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x9dc579bffde7d4118fef0090279cd0f9,00.html
Did you take a backup?
Gary Cooper_1
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

Wodisch,

I thought I'd cracked it there for a moment. The "who am i -u" command looked like it would allow me to do what I wanted to do. I tried it both from the Unix console and via my Xterm on my PC (XDMCP) and it looked fine. So, I changed my script and than it just wouldn't log me in at all!

It seems that the "who am i -u" works as root (how I first ran it), but not when run as a normal user. (It complains of the usage and lists the options).

Both root and user are using /usr/bin/who.

Any suggestions?

Thanks,

Gary
harry d brown jr
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem


I was starting to write this.(BELOW ->)..when I had a "moment"...:

I'm sorry, but how is xhost going to help set his DISPLAY variable? He's NOT having connection issues, he's having issues with getting the DISPLAY variable to work correctly....

(so ignore that paragraph and read on...)

So I flashed back to Gary's last comment about not being able to LOGIN. Boy this is something new. Why wasn't this part of the original issue?

Gary, you have a script to login to another machine? Could you kindly POST that script so that we can see what the hell is going on?

If you are using xterm on the remote host you can use the -display option to set the DISPLAY!!!


thanks,

live free or die
harry
Live Free or Die
Ceesjan van Hattum
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

The solution! First a snapshot of the manual:

The terminal type specified by the current TERM environment variable
is propagated across the network and used to set the initial value of
your TERM environment variable on the remote host. Your terminal baud
rate is also propagated to the remote host, and is required by some
systems to set up the pseudo-terminal used by rlogind (see
rlogind(1M)).

SO LOOK AT THE FOLLOWING:

$> export TERM="iamcrazy"
$> rlogin HOST2
$>> echo $TERM
$>> iamcrazy

THIS IS POSSIBLE, BUT YOU NEED TO EDIT THE PROFILES.

So what you should do before the first rlogin:
export TERM=`who am i -u | awk '{print $8}'

Then, on all systems you should precede the TERM-settings in the /etc/profile and .profile (don't forget /etc/skel/profile for each new user):

change it to:
export DISPLAY=$TERM
TERM=""
..old set-term procedure..

I tested it and works just fine. And if you don't like to set each time the TERM value before each rlogin, then make your own rlogin:

PATH=/usr/local:/usr/bin
/usr/local/rlogin:
export TERM=`who am i -u | awk '{print $8}'
/usr/bin/rlogin $1

Regards,
Ceesjan
Jean-Luc Oudart
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

Ceesjan,

This is quite like my post yesterday !

Use the TERM variable to transport the necesary information.

Jean-Luc
fiat lux
Ceesjan van Hattum
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

Jean-Luc, yes, you are right. It is the same.. sorry, i overlooked your reply.
But you and me both agree that this trick can be used. Now i just don't understand why you only got 3 points.. this solution not appriciated?

Greetings,
Ceesjan
Jean-Luc Oudart
Honored Contributor

Re: Bet you can't solve my $DISPLAY problem

I suspect my solution was not tested by Gary :-(
Jean-Luc
fiat lux
Gary Cooper_1
Esteemed Contributor

Re: Bet you can't solve my $DISPLAY problem

Ceesjan, Jean-Luc

I suspect that you are saying is correct when doing an rlogin (and my complete solution would ideally cope with this scenario as well), however, my main focus at the moment is for my users that don't (can't) do an rlogin. I.e. how to set up DISPLAY when XDMCP'ing from my PC/X-Term emulator and also when logging on at the console.

Thanks,

Gary