Error in remote script

cat raj
var='Dir=cd /opt/sybase/dba;
pwd;
echo $Dir;
cd $Dir;
pwd;
a=`ls -lrt|awk \'{print $9}\'`;
echo $a'
ssh $SERVER $var >>test.out

---
sh raj test_host
error:
raj: syntax error at line 4: `end of file' unexpected

a=`ls -lrt|awk \'{print $9}\'`; ---- i hv used escape sequence \ for '.Pls let me know how this can be corrected.

Thanks in advance
Raju

what does this mean??

var='Dir=cd /opt/sybase/dba;

actually i want to execute script $var in a remote host.
so var has stores the everythin in between 'single quotes' (end of single quote is seen at -echo $a')

SERVER=$1
#ssh "$SERVER" \
var='Dir=cd /opt/sybase/dba;
pwd;
echo $Dir;
cd $Dir;
pwd;
a=`ls -lrt`;
echo $a'
ssh $SERVER $var >>test.out

above one gives correct output

but i want to use awk command in it

so am giving
a=`ls -lrt|awk \'{print $9}\'`; ---which is giving an error i think it is due to single quote

i can modify the output to achieve the result but this is a sample code and the similar functionality has to be used in another script.