Auto X when Login

Hi All,
We have some HP unix servers and sometimes we logon there thru a dedicated Windows server that has Reflection X on it in case we need X. In this case we always need to export DISPLAY=winservername:0.0

I want to automate this thing in .profile file. If e.g. $TERM = hpterm (thru reflection X) then it should automatically export DISPLAY. (I found out that TERM=hpterm always indicates if we logon thru the windows server, because otherwise it is just set to "hp". So I can use this condition)

It's all OK, I can do that. But I came across an issue when e.g. I logon to the windows server as the first person and open a reflection X then DISPLAY should be sever:1.0
But when another chap comes thru this windows server and opens a reflection X session then he must export DISPLAY=winserver:2.0.

So it seems this number is increasing with any further parallel sessions get opened from the Windows machine.

Is there any way or UNIX command how I can find out what this number should be after the server? Then I can really automate this DISPLAY export and it would not only work for the first user who opens an X session.

So I need something like this:
if $TERM = "hpterm" then export DISPLAY=winserver:$n.0

and I need to know how $n can be determined for the given session.

Cheers

Very tricky what you are asking since I never tried to use RX from a Winserver...
but from what I know of the product when you try a connection the script lauched by Rx to open a session on a server looks like:
(/usr/bin/X11/dtterm -display %IP#% -name %T% &)
which would get your pc's IP and open a dtterm...
What you are doing is a bit different since you are a few opening on the same Winserver a new Xserver instance thus the :1.0, :2.0 etc
You should remember that if RX can open multiple instances, there is a limit...
Go and see attachmate's site if you can find some documention there or try to get some support

add the following to the unixID's .profile

 if tty -s; then
    DISPLAYHOST=$\(who -muR | awk '\{print $NF\}'\)
    DISPLAYHOST=$\{DISPLAYHOST%%:0.0\}
    DISPLAY=$DISPLAYHOST:0.0; export DISPLAY
    echo "DISPLAY has been set to $DISPLAY"
 fi

try it, you'll like it :smiley: