[lug] Problem with $DISPLAY script and SSH.

Harris, James A (Jim) HarriJA at LOUISVILLE.STORTEK.COM
Wed Feb 2 18:07:28 MST 2000


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




More information about the LUG mailing list