How to automatically set the DISPLAY var?

Hi all,

Our users use Putty on Windows servers to log on to UNIX via SSH and run GUI applications. Is there a way to automatically get the display numbers from xming or Exceed (that are running on Windows) to set the DISPLAY var properly on UNIX? X11 forwarding is not an option.

The closest I came to this was to get rid of the hostname with the following:

display(){
export MYTERM=$(who am i | awk '{print $2}')
export DISPLAY=$(who -u -m | grep $MYTERM | awk '{print $8}' | sed 's/[()]//g'):$1.$2
echo "DISPLAY="$DISPLAY
}

Then run it like this:

display n m

...where n and m are the Exceed or xming display numbers.

I would suggest something like this in your .profile (or whatever):-

export DISPLAY="${SSH_CLIENT%% *}:$n.$m"

.... where you can set $n and $m to whatever you like.

Does that get you anywhere?

Robin

Using SSH_CLIENT seems to be a very nice shortcut for the code I've initially posted.

But I'm curious if there's a way on finding out $n and $m from UNIX.

Have you considered using X encapsulation via ssh ?
If you do that, no need to export anything, it will just work.

From linux client you will use ssh -Y ...
If you are using putty, then you can setup the encapsulation in it.

What happens is when you ssh to machine and check display is after connecting is :
[host ~]$ echo $DISPLAY
localhost:10.0

Hope the helps
Regards
Peasant.