Tuesday, January 16, 2007

Setting DISPLAY variable


How about exporting the DISPLAY variable in a generic way? (instead of hardcoding it to specific IP address in .bash_profile e.g DISPLAY=172.22.21.21:0.0) , usually ip address is the address of the workstation on which the GUI(windows) from linux are to be displayed.

If you are in an working environment where you used to telnet to linux boxes (using putty or cmd line from windows boxes), and you want the linux application GUIs to be displayed in your local windows box(from where you are telneting), I feel this is the best way of doing that.

in .bash_profile/.profile

DISPLAY=`who am i | awk '{print $6}' | cut -d"(" -f2 | cut -d")" -f1`:0.0; export DISPLAY

or

DISPLAY=`who am i | awk '{print $NF}' | sed -e 's/(//g' -e 's/)//g'`:0.0; export DISPLAY

So its more generic, will take the IP address of the local box from where you are telnetting to the Linux box

1 comment:

neighborhoodjudge said...

Thanks,

I'm automatically switching to bash when I log into an AIX box; I had to put this into my .bashrc file rather than .profile, but it works like a dream.

© Jadu Saikia www.UNIXCL.com