Created
August 12, 2013 20:20
-
-
Save JorgenEvens/6214764 to your computer and use it in GitHub Desktop.
Connects to a VNC console on a xen host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOST=$1 | |
PORT=$2 | |
RUN=true | |
SOCK=`mktemp -t xenvnc.$HOST.$PORT.XXX` | |
rm $SOCK | |
ssh $HOST -f -q -S $SOCK -L $PORT:localhost:$PORT sleep 1d | |
close_connection() { | |
RUN=false | |
} | |
trap close_connection 1 2 3 15 | |
while $RUN | |
do | |
vncviewer localhost:$PORT 2> /dev/null | |
done | |
echo "Closing ssh connection ($SOCK)" | |
ssh -S $SOCK -O exit $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment