title: Bad stdio forwarding specification '%h:%p''
body: <p>[OS - macOS, Shell - Bash]</p>
  
  <p>I have a small bash script that generates a ssh command based on input parameters. The command generated is:</p>
  
  <pre><code>ssh -o ProxyCommand='ssh &lt;bastion_name&gt; -W %h:%p' -A -D &lt;port&gt; &lt;username&gt;@&lt;destination_host_name&gt;
  </code></pre>
  
  <p>The script stores this command in a variable say cmd, where</p>
  
  <pre><code>cmd="ssh -o ProxyCommand='ssh $1 -W %h:%p' -A -D $3 $4@$2"
  </code></pre>
  
  <p>where $1 = bastion_name, $2 = destination_host_name, $3 = port and $4 = username.</p>
  
  <p>and then it tries to execute the command like,</p>
  
  <pre><code>echo "Executing --&gt; $cmd"
  $cmd
  </code></pre>
  
  <p>but it terminates with following error,</p>
  
  <pre><code>Bad stdio forwarding specification '%h:%p''
  </code></pre>
  
  <p>But since I am echoing the cmd, I copy paste directly in terminal and it runs without any error.</p>
  
  <p>Please note the bastion_name is resolved via ssh config which has the username and other attributes defined for that bastion host.</p>
  
  <p>What's the problem here because obviously the command is correct ?</p>