tags:

views:

37

answers:

1

I have a bash script which I wrote that lists out some servers/user names. I chose a # which then connects me to said server with said user name. So far the script works fine other then the fact that when I launch ssh, the bash script hangs. It doesn't dump me into ssh.

#!/bin/bash
echo `clear`
SERVER1="1.) Server1/username1"
SERVER2="2.) Server1/username2"
echo -e "Please choose a server:"
echo $SERVER1
echo $SERVER2
read server
if [ $server -eq 1 ]; then
        serverconnect="ssh -t [email protected]"
        servername="server1.com"
        serveruser="username1"
else

        if [ $server -eq 2 ]; then
                serverconnect="ssh -t [email protected]"
                servername="server1.com"
                serveruser="username2"
        fi
fi

echo "Connecting you to: $servername as $serveruser"
echo `$serverconnect`
+3  A: 

just execute ssh normally. Don't put it inside variable

if [ $server -eq 1 ]; then
        serverconnect="[email protected]"
        servername="server1.com"
        serveruser="username1"
else

        if [ $server -eq 2 ]; then
                serverconnect="[email protected]"
                servername="server1.com"
                serveruser="username2"
        fi
fi

ssh -t "$serverconnect" 
ghostdog74