I want to make an alias that is kept in my bashrc file to log into a remote MySQL db via SSH. Assume that I can't add/alter any files on the remote machine that I'm SSHing into. Here's the relevant code.
function ssh_mysql {
echo "SSHing to $server"
ssh -t -t $suser@$server <<ENDSSH
eval "mysql -h "$host" -u $user -p $pass $db"
ENDSSH
}
alias wt_mysql=ssh_mysql
The Problem: Entering 'wt_mysql' into the terminal as an alias SSHs and logs into MySQL fine.. but when trying to enter any command/query/etc at the MySQL prompt, none of what I've submitted is executed/run. Including the 'exit' command. I have to ctrl C to get back to my local terminal. although its a bit out of my understanding I believe the problem is related to this topic, Terminating SSH session executed by bash script
How can I make sure that mysql and any subsequent commands are executed remotely?
Thanks!
function ssh_mysqland thenalias wt_mysql=ssh_mysqlinstead of defining onlyfunction wt_mysql? I assume in my answer that you get the same problem runningssh_mysqlas you do runningwt_mysql, but if that is the case then why did you tell us about the alias? In general you should make it easy for people to help you by simplifying your question as much as possible.