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 example.com/?a=1,2,3&m=a,b,c'

the actual command that needs to reach serverB is:

processthis -a example.com/?a=1,2,3&m=a,b,c

but the command that reaches there is

processthis -a example.com/?a=1,2,3

Thanks

link|improve this question

79% accept rate
feedback

2 Answers

up vote 2 down vote accepted

Try putting a double quote around the argument to processthis.

ssh root@serverB 'processthis -a "example.com/?a=1,2,3&m=a,b,c"'

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

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

sh root@serverB 'processthis -a example.com/?a=1,2,3\&m=a,b,c'

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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