| version 1.2, 2002/02/04 14:26:31 |
version 1.3, 2002/03/12 18:33:38 |
|
|
| # Use this script to connect to remote host |
# Use this script to connect to remote host |
| # if you will running X aplications on this host |
# if you will running X aplications on this host |
| |
|
| # On remote host put these lines to your ~/.tcshrc if you |
# On remote host put these lines to your ~/.tcshrc if you #%# {{{ |
| # are using tcsh shell. |
# are using tcsh shell. |
| |
|
| #!/usr/bin/tcsh |
##!/usr/bin/tcsh |
| # |
# |
| # Set $DISPLAY enviroment if there is a record in ~/.Xauthority file |
## Set $DISPLAY enviroment if there is a record in ~/.Xauthority file |
| # and user is logged in via ssh |
## and user is logged in via ssh |
| #if ( $shlvl == 1 ) then |
#if ( $shlvl == 1 ) then |
| # unsetenv DISPLAY |
# unsetenv DISPLAY |
| # if ($?SSH_CLIENT) then |
# if ($?SSH_CLIENT) then |
| # set DISP=`printenv SSH_CLIENT | awk '{print $1 }'`":0" |
# set DISP=`printenv SSH_CLIENT | awk '{print $1 }'`":0" |
| # set count=`xauth list | grep ^$DISP| wc -l` |
# set count=`xauth list $DISP | wc -l` |
| # if ( $count == 1 ) then |
# if ( $count == 1 ) then |
| # echo "Setting DISPLAY "`(printenv SSH_CLIENT | awk '{print $1 }')`":0" |
# echo "Setting DISPLAY "`(printenv SSH_CLIENT | awk '{print $1 }')`":0" |
| # setenv DISPLAY `printenv SSH_CLIENT | awk '{print $1 }'`:0 |
# setenv DISPLAY `printenv SSH_CLIENT | awk '{print $1 }'`:0 |
| # endif |
# endif |
| # endif |
# endif |
| #endif |
#endif |
| |
#%# }}} |
| |
|
| |
## On remote host put these lines to your ~/.zshrc if you ## {{{ |
| |
## are using zsh(|bash?) shell. |
| |
# |
| |
## set $DISPLAY enviroment using $SSH_CLIENT |
| |
#disp() |
| |
#{ |
| |
# local DISP count |
| |
# export DISPLAY= |
| |
# if [ $?SSH_CLIENT ]; then |
| |
# DISP=( `printenv SSH_CLIENT | awk '{print $1 }'`:0 ) |
| |
# count=( `xauth list $DISP | wc -l` ) |
| |
# if [ $count = 1 ]; then |
| |
# if [ $SHLVL != 1 ]; then |
| |
# echo "Setting DISPLAY $DISP" |
| |
# fi |
| |
# export DISPLAY=$DISP |
| |
# fi |
| |
# fi |
| |
#} |
| |
## }}} |
| |
# |
| |
## If login shell then set display |
| |
#if [ $SHLVL = 1 ]; then |
| |
# disp |
| |
#fi |
| |
|
| |
|
| if [ $# -lt 1 ]; then |
if [ $# -lt 1 ]; then |
|
|
| # Export ~/.Xauthority file to remote host |
# Export ~/.Xauthority file to remote host |
| # |
# |
| echo "Running xauth..." |
echo "Running xauth..." |
| UNAME=`uname -n` |
#xauth extract - $DISPLAY | ssh $* xauth merge - |
| ssh $* xauth add `xauth list |grep -v unix:0 | grep $UNAME` |
#ssh $* xauth add `xauth list |grep -v unix` |
| |
XAUTH_HOST_IP=`hostname -i | awk 'BEGIN {RS = " "} {print}' | awk '/^$/ {next;} ! /^127.0.0.1$/ {print}'` |
| |
DISP=`xauth list $XAUTH_HOST_IP:0 | awk "{print \"$XAUTH_HOST_IP:0 \" \\$2 \" \" \\$3}"` |
| |
ssh $* xauth add "$DISP" |
| |
|
| if [ $? -ne 0 ]; then |
if [ $? -ne 0 ]; then |
| echo "$0: Can't export \$DISPLAY to remote host, exiting ..." |
echo "$0: Can't export \$DISPLAY to remote host, exiting ..." |
|
|
| echo "Connecting with ssh..." |
echo "Connecting with ssh..." |
| ssh $* |
ssh $* |
| |
|
| |
# Modeline for ViM {{{ |
| |
# vim:set ts=4: |
| |
# vim600:fdm=marker fdl=0 fdc=3: |
| |
# }}} |