[Gllug] automagic DISPLAYs
tet at accucard.com
tet at accucard.com
Tue Sep 18 12:16:48 UTC 2001
>I want to get the DISPLAY environment variable set to the hostname from
>which I logged in from, anyone think of a reliable method?
>From my home machines:
if [ -z "$DISPLAY" ]
then
login_from=`wherefrom`
case "$login_from" in
:*) ;;
*)
if [ ! -z "$login_from" ]
then
DISPLAY="$login_from:0"
export DISPLAY
fi
;;
esac
unset login_from
fi
"wherefrom" is a simple C application I wrote that makes use of getutent()
and the ut_addr field of struct utmp to find out where you logged in from.
I initialyl tried parsing the output of "who" instead, but it didn't prove
as reliable as I needed when I originally wrote it.
Yeah, it's pretty crude, but it works most of the time. It doesn't handle
multiple levels of indirection though (i.e., if you log into somewhere else
from the remote box, then it will redirect DISPLAY back to the first remote
box, rather than the original source machine). I believe ssh can be
configured to do X forwarding properly over multiple hops. It also doesn't
handle multiple screens and/or displays on the originating machine.
>Don't suggest ssh X redirection, machines have no X libraries :)
ssh should be able to do pure port redirection without having X
libraries on the box itself. Not that I've looked into it. The above
script works fine for the home network, and at work, none of the
remote boxen have X installed, so I've never needed to do $DISPLAY
redirection.
Tet
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list