title: How do I escape strings in logstash
body: <p>I am using the <code>exec</code> input plugin. The shell command I want to execute includes single and double quotes already. How do I escape it properly?</p>
  
  <pre><code>input {
      exec {
          command =&gt; 'curl -i -X POST -H "Content-Type:application/json" -d '{"this":"that"}' http://a_url'
      }
  }
  </code></pre>
  
  <p>This example fails because the single quotes wrapping the command interfere with the single quotes around the <code>curl</code> data option.</p>
  
  <p>Any help would be appreciated, I am too frustrated to think.</p>
  
  <p>EDIT - I think I got it.</p>
  
  <p>I changed the quotes for <code>-d</code> to double quotes. Then I escaped the double quotes in the json:</p>
  
  <pre><code>-d "{\"this\":\"that\"}"
  </code></pre>
  
  <p>Finally, one of the items in my json was a password that included a <code>$</code>. I had to escape it too:</p>
  
  <pre><code>-d "{\"this\":\"tha\$t\"}"
  </code></pre>
  
  <p>That was not fun.</p>