Making an alias for SSH MySQL login using ENDSSH heredoc

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"
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!


I don't understand why you're using eval (or why you're passing the -t switch twice).

I would expect this ssh command to do what you want:

ssh -t $suser@$server "mysql -h '$host' -u $user -p $pass $db"

Need Your Help

Hadoop namenode format not working


I've been trying to install hadoop 2.7.0 on Ubuntu but when i enter the hadoop namenode -format command i get the following message:

cocos2D and Box2D : How to get exact touched sprite?

iphone cocos2d-iphone box2d

I am trying to move sprite on touch moved. but when two sprites is there i am geting touch of two sprites. that's why sprites are not moving properly.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.