title: Expanding variable with spaces into a curl POST variable
body: <p>Some research revealed a few useful stackexchange posts, namely <a href="https://stackoverflow.com/questions/4152388/expanding-variable-in-curl">expanding variable in CURL</a>, but that given answer doesn't seem to properly handle bash variables that have spaces in them.</p>
  
  <p>I am setting a variable to the output of awk, parsing a string for a substring (actually truncating to 150 characters).  The string I am attempting to POST via curl has spaces in it.</p>
  
  <p>When I use the following curl arguments, the POST variable <code>Body</code> is set to the part of the string before the first space.</p>
  
  <p><code>curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/GUID/SMS/Messages.xml' -d 'From=DIDfrom' -d 'To=DIDto' -d 'Body="'$smsbody'" -u SECGUID</code></p>
  
  <p><code>smsbody</code> is set as:</p>
  
  <p><code>smsbody="$(echo $HOSTNAME$ $SERVICEDESC$ in $SERVICESTATE$\: $SERVICEOUTPUT$ | awk '{print substr($0,0,150)}')"</code></p>
  
  <p>So the only portion of <code>smsbody</code> that is POSTed is <code>$HOSTNAME$</code> (which happens to be a string without any space characters).</p>
  
  <p>What is the curl syntax I should use to nest the bash variable properly to expand, but be taken as a single data field?</p>
  
  <p>Seems pretty trivial, but I messed with quotes for a while without luck.  I figure someone with better CLI-fu can handle it in a second.</p>
  
  <p>Thanks!</p>