title: Read commands from test file and execute
body: <p>I am trying to write a shell testing program which compares the output for my program with the sample program. I have stored a list of command in a text file, it looks like this:
  commands.txt:</p>
  
  <pre><code>echo line A &gt; a
  echo line A &gt; b    
  ./program a b
  </code></pre>
  
  <p>and the shell test looks like this:</p>
  
  <pre><code>cat $testname | while read LINE
  do  
     echo -e "$LINE$"
     $LINE
  done
  </code></pre>
  
  <p>but rather than crating files a and b the program produces the flowing:</p>
  
  <pre><code>echo line A &gt; a
  line A &gt; a
  echo line B &gt; b
  line B &gt; b
  </code></pre>
  
  <p>How can I execute the command just like it was written in the shell file and redirect the out put to another file?</p>