I'm trying to create a simple script for logging into various servers via ssh, all keys have been installed and are working but i simply cannot get this script to work for me. Basically there is an option as to which server the user wishes to login to but it keeps throwing up the following error:
': not a valid identifier `INPUT
login.sh: line 24: syntax error near unexpected token `elif'
'ogin.sh: line 24: `elif [ $INPUT -eq 2 ] ; then
The script layout can be found below with dummy info:
#!/bin/bash
echo "What Server would you like to login to?"
echo ""
echo ""
echo "1. Server 1"
echo "2. Server 2"
echo "3. Server 3"
echo "4. Server 4"
echo "5. Exit"
read INPUT
if [ $INPUT -eq 1 ] ; then
echo"Logging in"
echo"..."
ssh root@1.2.3.4 -p 5678
elif [ $INPUT -eq 2 ] ; then
echo"Logging in"
echo"..."
ssh root@1.2.3.4 -p 5678
elif [ $INPUT -eq 3 ] ; then
echo"Logging in"
echo"..."
ssh root@1.2.3.4 -p 5678
elif [ $INPUT -eq 4 ] ; then
echo"Logging in"
echo"..."
ssh root@1.2.3.4 -p 5678
elif [ $INPUT -eq 5 ] ; then
exit 0
else
echo "invalid choice"
return
fi
Any help would be greatly appreciated, relatively new to using bash and this is just annoying me now!