Operating System - HP-UX
1753707 Members
4990 Online
108799 Solutions
New Discussion юеВ

Re: exporting DISPLAY variable on rlogin

 
SOLVED
Go to solution
Frost Support
Occasional Contributor

exporting DISPLAY variable on rlogin

Hi

When remote logging into another HP box, I have to manually export the DISPLAY variable to run SAM.

A section of the .profile is as follows :-

exportPS1="${LOGNAME}@$(hostname)"'[${PWD##*/}] '
Where=`who am i -Rm | awk '{print $NF}' | sed -e "s/^(//" -e "s/)$//" | grep -v $(hostname)`
if [ "${Where}" ] ; then
export DISPLAY="${Where}:0"
fi

When using rlogin the DISPLAY variable Where is not exported.

Can anyone reason why ?
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor

Re: exporting DISPLAY variable on rlogin

Hi,

I use this one,

if [ ! "$VUE" ]; then

# -- Do trick to set the display in case of remote login
HOST=`who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"`
if [ "$HOST" != "" ] && [ "$HOST" != ":0" ] && [ "$HOST" != ":0.0" ];
then
if [ "$HOST" = `who am i -R |awk '{print $NF}' | sed "s/(\(.*\))/\1/"` ]
then
HOST=$HOST:0.0
fi
echo " +--<<"
echo " | Remote login detected, setting DISPLAY to $HOST"
echo " +-->>"
DISPLAY=$HOST
export DISPLAY
fi

Hope it helps,

Robert-Jan.
Pete Randall
Outstanding Contributor
Solution

Re: exporting DISPLAY variable on rlogin

Rather than rlogin, we use a remsh technique thusly:

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


The available hostnames become mini scripts that call this script with their own hostname as an argument. So, if you want to "rlogin server1", you would just enter "server1" and a hpterm (or dtterm) window pops up with the display already set.


Pete

Pete
John Meissner
Esteemed Contributor

Re: exporting DISPLAY variable on rlogin

I use either:
me=$(who -mT | awk '{print $9}')
export DISPLAY=$me:0.0

or
ip=$(last -R | grep `whoami` | grep in$ | sed -n '1p' | awk '{print $3}')
export DISPLAY=$ip:0.0


All paths lead to destiny
Holger Dietze
Occasional Advisor

Re: exporting DISPLAY variable on rlogin

if it is only sam you wish to use, sam has a section for running remote sam. You do not need to remsh/rlogin manually, sam help you setup this.
Frost Support
Occasional Contributor

Re: exporting DISPLAY variable on rlogin

Many thanks for all the replies on this one. I used the remsh option as a single script and this works fine.
Bill McNAMARA_1
Honored Contributor

Re: exporting DISPLAY variable on rlogin

heres what I use:

# Set prompt
export PS1=$(whoami)"@"$(hostname)" "\$PWD" "$(echo "\n# ")

# Set DISPLAY :
export DISPLAY=$(who am i -R | cut -d"(" -f 2|cut -d")" -f1):0.0
echo "My display is $DISPLAY"
It works for me (tm)
RolandH
Honored Contributor

Re: exporting DISPLAY variable on rlogin

You can also use

/usr/contrib/bin/X11/xon

to set your display automatically.

Roland

Sometimes you lose and sometimes the others win