I'm trying to automate a Magento site build and one of the challenges I'm having is updating the content of a page in the database through a command. When trying to do:
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES ("<p style="text-align: center;"><a href="http://www.magentocommerce.com/knowledge-base"><img src="{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}" alt="" width="1200" height="630"></a></p>");"
I'm receiving this error:
-bash: syntax error near unexpected token `<'
I'm by no means a DBA, but I have a feeling the issue is that I'm not properly escaping the double quotes, or that it's running into the terminating ';' in the middle of the HTML and failing.
Any help would be appreciated.
You have to escape the double quote with \
them when you using them to mark the string start and end
mysql -D magento -e "INSERT INTO cms_page ('content') VALUES (\"<p style=\"text-align: center;\"><a href=\"http://www.magentocommerce.com/knowledge-base\"><img src=\"{{media url="36d3c9416834b86ba9a78b92d97325f556a2f32f.png"}}\" alt=\"\" width=\"1200\" height=\"630\"></a></p>");"