[lug] Problem with $DISPLAY script and SSH.

Walter Pienciak walter at frii.com
Wed Feb 2 18:49:17 MST 2000


On Wed, 2 Feb 2000, Harris, James A (Jim) wrote:

> Hi all -
> 
> I need a little help enhancing an extremely simple little script I've put in
> my .profile.  I put the following line in so that my display variable is
> updated with the host I'm logging in from automatically.  The line looks
> like this:
> 
> DISPLAY=$REMOTEHOST':0.0'; export DISPLAY
> 
> Insanely simple, I know.  :)  Here's the problem I'm running into:  when I
> log in using SSH this little export is overwriting the DISPLAY variable that
> the SSH client sets up for X11 forwarding.  (It sets the DISPLAY variable to
> LOCALHOST:10.0)  I'm looking for a way to make the script intelligent enough
> to detect that I'm coming in from SSH and not reset the variable if I am.
> Since SSH comes in through port 22, I thought a simple logic statement that
> says "if it's comin' in from 22, don't run the next line" would work, but
> I'm not sure how to do that.  (I'm not terribly competent with shell
> scripting yet.)
> 
> Could anyone help me write something to do this?
> 
> Thanks much!!
> -Jim

Hi,
 
Look at the results of the env command when you're logged in via ssh.
SSh sets a few variables that don't exist otherwise: SSH_CLIENT, SSH_TTY

Walter





More information about the LUG mailing list