title: How to open a bash/ssh session in shell script and run commands in the remote session?
body: <p>I try to do the following in a shell script:</p>
  
  <pre><code>bash;
  </code></pre>
  
  <p>in the bash context:</p>
  
  <ul>
  <li>run <code>./a.out</code></li>
  </ul>
  
  <p>And In <code>./a.out</code> context I need to simulate keystorkes:</p>
  
  <pre><code>yes
  3292
  no
  </code></pre>
  
  <p>How can I do it? All my tries failed since <code>&amp;</code>, <code>&amp;&amp;</code> and <code>;</code> executes the subsequent command in the main shell context and not in the bash.</p>
  
  <pre><code>bash &amp;&amp; echo "yes" &gt; /dev/console
  </code></pre>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/5174813/use-expect-in-shell-script">use expect in shell script</a> aren't there any alternative using native shell commands ? I don't want to be dependent on other tools.</p>