sed command via SSH not working as expected



Hi,

I am using openssh from Debian Lenny which is version 1:5.1p1-5.

I am using ssh to run a command on a remote host running Debian Lenny as
well.

The line I am editing with sed looks like this:
'(proxyAddresses=*)' 2>$ERRORLOG | $GREP -if $RELAYDOMAINS | $GREP -Fi
smtp \

I am running the following command to update the line as follows:
ssh root@xxxxxxxxxxxxxxxxxx "sed -i 's/$GREP -Fi smtp/$GREP -Fi smtp |
$SORT -u/' /usr/local/bin/script.sh"

But what I find is that the line ends up looking like this on the remote
host:
'(proxyAddresses=*)' 2>$ERRORLOG | $GREP -if $RELAYDOMAINS | $GREP -Fi
smtp | -u \

The important part being "| -u" which should look like "| $SORT -u".

This command works fine when running it on the command line directly.

Could I be missing something or perhaps this is a bug?

Thanks,

James