title: How to get output of sqlite command in shell script
body: <p>I am trying to make rollback if something went wrong during the execution of my sql crud operations or if it can not make commit with shell scripting.</p>
  
  <p>I have test2.sh and test.sh 
  test.sh:</p>
  
  <pre><code> #!/bin/sh
   sqlite3 dB.sqlite &lt;&lt; EOF
   begin;
   select * from Table1; 
  </code></pre>
  
  <p>and test2.sh</p>
  
  <pre><code>#!/bin/sh
  if echo `./test.sh`|grep -q "SQL error"; then
    rollback;
  else
    err=commit;
    if echo $err |grep -q "error"; then
      rollback;
    fi
  fi
  </code></pre>
  
  <p>There is no table called Table1 and i expected to get the sql error output of test.sh and rollback. </p>
  
  <p>But it gives error : rollback: command not found.
  How can i get the error and make rollback? or Is this way that i follow right?</p>