OSX, bash, cat with <<MARKER executing commands

I have a script that writes another script with

cat >/usr/local/bin/myscript.sh <<EOF
#!/bin/sh
VAR=`run a command here`
EOF

Problem is, after this is run, I get:

$ cat /usr/local/bin/myscript.sh
#!/bin/sh
VAR=result of command

How do I stop that from happening with Macs BSDish shell?

To avoid command substitution in a here-document you need to quote at least one character in the delimiter. Try:

cat >/usr/local/bin/myscript.sh <<"EOF"
#!/bin/sh
VAR=`run a command here`
EOF

Thank you!!!