title: URL encoding a string in bash script
body: <p>I am writing a bash script in where I am trying to submit a post variable, however wget is treating it as multiple URLS I believe because it is not URLENCODED... here is my basic thought</p>
  
  <pre><code>MESSAGE='I am trying to post this information'
  wget -O test.txt http://xxxxxxxxx.com/alert.php --post-data 'key=xxxx&amp;message='$MESSAGE''
  </code></pre>
  
  <p>I am getting errors and the alert.php is not getting the post variable plus it pretty mush is saying </p>
  
  <p>can't resolve I
  can't resolve am
  can't resolve trying
  .. and so on.</p>
  
  <p>My example above is a simple kinda sudo example but I believe if I can url encode it, it would pass, I even tried php like:</p>
  
  <pre><code>MESSAGE='I am trying to post this information'
  MESSAGE=$(php -r 'echo urlencode("'$MESSAGE'");')
  </code></pre>
  
  <p>but php errors out.. any ideas? How can i pass the variable in $MESSAGE without php executing it?</p>