Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following command works as expected:

ssh soak@ "ssh soak@ "mysqlshow""

But the following does not:

ssh soak@ "ssh soak@ "mysql test -Bse"show variables""" 

The following part works at the command prompt but fails when I do ssh before executing it as shown above.

mysql test -Bse"show variables"
share|improve this question
up vote 4 down vote accepted

You can't nest double-quotes like that. You either need to escape them or change your approach.

Try this:

ssh soak@ "ssh soak@ \"mysql test -Bse'show variables'\""
share|improve this answer
ssh soak@ "ssh soak@ \"mysql test -Bse'show variables'\"" – shantanuo Sep 26 '11 at 8:41
Ah, yeah, of course you need the outer most quotes too. I'll fixup my answer. – P.T. Sep 26 '11 at 8:46

In the command ssh soak@ "ssh soak@ "mysql test -Bse"show variables""" you have multiple double quotes. Try escaping them

ssh soak@ "ssh soak@ \"mysql test -Bse\\\"show variables\\\"\""
share|improve this answer

Alternatively, you can put

mysql test -Bse"show variables" 

into a script on your server and then just call that script via SSH as you showed in your first example. If you do this, make sure the executable bit is set properly to allow user soak to run it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.