Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I have 2 servers both ubuntu say serverA and serverB

I am running a shell command from serverA on the shell of serverB but it seems I need to do some escaping for the exact command to reach serverB. The command on serverB doesnt have & and anything after that. Is there anyways I can make sure exact command reaches the serverB:

I am doing this on serverA

ssh root@serverB 'processthis -a,2,3&m=a,b,c'

the actual command that needs to reach serverB is:

processthis -a,2,3&m=a,b,c

but the command that reaches there is

processthis -a,2,3


share|improve this question
up vote 2 down vote accepted

Try putting a double quote around the argument to processthis.

ssh root@serverB 'processthis -a ",2,3&m=a,b,c"'

share|improve this answer
Thanks I tried the double quote approach and it worked. Thanks – Sparsh Gupta Mar 2 '11 at 16:31

You should escape the & with an \ as it gets treated by bash. Try this:

sh root@serverB 'processthis -a,2,3\&m=a,b,c'

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.