How to automatically set the DISPLAY var?

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions How to automatically set the DISPLAY var?
# 1  
Old 05-08-2014
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:

Code:
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:

Code:
display n m

...where n and m are the Exceed or xming display numbers.
# 2  
Old 05-08-2014
I would suggest something like this in your .profile (or whatever):-
Code:
export DISPLAY="${SSH_CLIENT%% *}:$n.$m"

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

Does that get you anywhere?



Robin
# 3  
Old 05-08-2014
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.
# 4  
Old 05-09-2014
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

DISPLAY not set

Hi, When i invoke DBCA as oracle user , i get following usircd01:KAM:/opt/oracle10/product/10.2.0/bin>./dbca DISPLAY not set. Set DISPLAY environment variable, then re-run. usircd01:KAM:/opt/oracle10/product/10.2.0/bin>echo $ORACLE_SID CCE ... (6 Replies)
Discussion started by: Maddy123
6 Replies

2. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Need a script for automatically cleaning up /var/spool/cups directory

Hi Friends, Actually in an linux server , there was printer jobs files occupying more space in /var/spool/cups so i want a script for deleting the files once in two week since i need the latest two weeks files. Thanks in advance..Waiting for the script. (2 Replies)
Discussion started by: Mohamed Thamim
2 Replies

4. Solaris

Set display to text

How do I set up my solaris 10 machine to display in text mode instead of graphics mode, permanently? (1 Reply)
Discussion started by: jastanle84
1 Replies

5. Shell Programming and Scripting

assign var with set=a[5] not working

Hi Experts, I'm having issue in assigning var with special character , please see below for complete details. $ echo $SHELL /bin/csh $ cat bp abd/asd/a $ awk -F "/" '{print $NF}' bp | awk '{print $1}' a $ set a=`awk -F "/" '{print $NF}' bp | awk '{print $1}'` $ echo $a ... (15 Replies)
Discussion started by: novice_man
15 Replies

6. UNIX for Advanced & Expert Users

Set ACL automatically for new folder/objects

Hi, In our bank production environment - IBM AIX 5.3, we have a particular parent folder inside which an application creates temporary folders & files. These temp folders exist for the lifetime of the user session within the application and then get deleted automatically. Since these temp... (1 Reply)
Discussion started by: deepaksinbox
1 Replies

7. Shell Programming and Scripting

How to set delete Key to erase automatically

We need to su to root in 1000 systems, so it is almost impossible to add "stty erase ^H" to every .profile on these systems. Is there any way to set delete key to erase automatically after running "su -"? Thanks :) (4 Replies)
Discussion started by: aixlover
4 Replies

8. Shell Programming and Scripting

Difference between "set $<var>" and "set -- $<var>"

Hi pros, Could anyone tell me the actual difference between setting the positional parameters from the variable using the following commands? $ var="This is my question" $ set $var $ echo $1 --> 'This' $ echo $2 --> 'is' .... .... and $ var="This is my question" $ set --... (3 Replies)
Discussion started by: royalibrahim
3 Replies

9. UNIX for Dummies Questions & Answers

set display

Hi All: An elementary Unix Question, How can i set the display number and run a program in that display. If i type the name of the executable the program opens in the console(display number 0), however, i want it to open in another display number. How can i do that. Appreciate the help... (2 Replies)
Discussion started by: preetham
2 Replies
Login or Register to Ask a Question