Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-setting DISPLAY variable in Solaris 1

Status
Not open for further replies.

khayr

Technical User
May 8, 2003
7
CA
Hello -

Problem: I often telnet to a unix server from different client machines. It would be helpful if the DISPLAY variable could be automatically set to the client upon login.

Question: Is there a command in Solaris to detect what the client display address is or some feature in the shell profile that can be turned on? I most often use bash shell.

Thanks in advance.
 
What are you using to telnet to the Unix system? An X window terminal emulator or plain vt100?
 
To clarify - I am trying to connect from other sun machines or via exceed x-window client.
 
Try this...
Code:
#!/bin/ksh

ME=$(who am i)
DISPLAY=${ME##*\(}
export DISPLAY=${DISPLAY%%\)*}:0

print "DISPLAY is set to ${DISPLAY}"
I'm sure others can do it prettier, but this should do it. It works on my systems.

Hope this helps.

 
Oops! Sorry. Just read that you use bash. This should do it for bash...
Code:
#!/usr/bin/bash

ME=$(who am i)
DISPLAY=${ME##*\(}
export DISPLAY=${DISPLAY%%\)*}:0

echo "DISPLAY is set to ${DISPLAY}"
This was tested on Solaris and seems to work fine.

Hope this helps.


 
SamBones - thanks, that worked! If you have the time, showing how we do it under csh and tcsh would be an asset.
 
I don't really know the C shell. I don't know but it might be something like...
Code:
setenv DISPLAY `who am i|sed -e 's/.*(//g;s/).*$//g;s/$/:0/'`
You could actually do the same with the Korn or Bourne shell. Or bash. It would be something like...
Code:
DISPLAY=`who am i|sed -e 's/.*(//g;s/).*$//g`:0
export DISPLAY
Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top