Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ $# = 0 ]]
- then
- echo "Use -a <name> to connect to server with name <name>"
- echo "Use -l command to get list of available servers with their names"
- echo "Use -h to get this help message again"
- exit 0
- fi
- while getopts a:lh option
- do
- case "${option}"
- in
- a) ADR=${OPTARG}
- REQ=0
- ;;
- l) REQ=1;;
- h) echo "Use -a <name> to connect to server with name <name>"
- echo "Use -l command to get list of available servers with their names"
- echo "Use -h to get this help message again"
- exit 0
- ;;
- *) echo "Unavailable option, use $0 -h to get help";;
- esac
- done
- declare -A NAMES
- NAMES[ivs]='root@123.123.123.123'
- NAMES[msu]='s02160069@prac.cs.msu.ru'
- if [[ ${REQ} = 1 ]]
- then
- echo "name address"
- for ind in "${!NAMES[@]}"
- do
- echo "${ind} ${NAMES[${ind}]}"
- done
- exit 0
- else
- ssh ${NAMES[${ADR}]}
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement