Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The following command works as expected:

ssh soak@10.10.10.11 "ssh soak@10.199.199.191 "mysqlshow""

But the following does not:

ssh soak@10.10.10.11 "ssh soak@10.199.199.191 "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
add comment

3 Answers

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@10.10.10.11 "ssh soak@10.199.199.191 \"mysql test -Bse'show variables'\""
share|improve this answer
    
ssh soak@10.10.10.11 "ssh soak@10.199.199.191 \"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
add comment

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

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

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
add comment

Your Answer

 
discard

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.