Hi,
Too bad you don't tell us what is going wrong. Looking at the code I see some things that are incorrect or could be improved.
This should work, using your original idea:
Code:
#!/bin/bash
server23()
{
ssh -p 23 username@$SERVER
}
SERVER="$1"
if [[ -f $PASSWD_FILE ]]; then
if [[ $SERVER == "server23" ]]; then
server23
else
grep $SERVER $PASSWD_FILE
ssh username@$SERVER
fi
fi
But the above can be done a lot simpler:
Code:
#!/bin/bash
SERVER="$1"
PORT="22"
[[ ${SERVER} == "server23" ]] && PORT="23"
ssh -p ${PORT} username@${SERVER}
Hope this helps.