you have to escape backquotes when creating scripts via cat << EOF :)