title: Cannot execute an AWS IOT command formed from a bash script
body: <p>I wrote the following bash script to send a command to my IOT device:</p>
  <pre><code>#!/bin/bash
  # target aws command
  # aws iot-data publish --topic 12345678_toDevice --qos 1 --payload ``echo '{&quot;command&quot;: &quot;do soemthing 90&quot;}' | base64`` --region us-west-2
  mac=$(cat mac.txt)
  #echo $mac 
  cmd1=&quot;aws iot-data publish --topic &quot;
  cmd2=&quot;_toDevice --qos 1 --payload \`echo '{\&quot;command\&quot;: \&quot;dosomething &quot;
  cmd3=&quot;\&quot;}' | base64\` --region us-west-2&quot;
  echo $cmd1$mac$cmd2$1$cmd3
  command=$($cmd1$mac$cmd2$1$cmd3)
  </code></pre>
  <p>Basically, the command gets the mac address of the device im trying to communicate with, and forms am aws command string, then executes it.</p>
  <p>When I run my script, I get this:</p>
  <pre><code>&gt;./setpos.sh 45
  
  usage: aws [options] &lt;command&gt; &lt;subcommand&gt; [&lt;subcommand&gt; ...] [parameters]
  To see help text, you can run:
  
    aws help
    aws &lt;command&gt; help
    aws &lt;command&gt; &lt;subcommand&gt; help
  
  Unknown options: &quot;dosoemthing, 45&quot;}', |, base64`, '{&quot;command&quot;:
  
  aws iot-data publish --topic 588E815CA84C_toDevice --qos 1 --payload `echo '{&quot;command&quot;: &quot;setDesiredPosition 45&quot;}' | base64` --region us-east-2
  </code></pre>
  <p>If I copy and paste the echo'ed command (last line) into bash, command works???? How do I get bash to format the command correctly so it can execute it from the script???</p>