title: how to run beeline and hive query from a bash shell script
body: <p>I am able to run below steps manually in order after logging in to unix bash shell.</p>
  <pre class="lang-sh prettyprint-override"><code>echo &quot;Connecting beeline&quot; 
  
  beeline
  !connect jdbc:hive2://a301-1234-1234.stm.XXX.com:10000/default;;ssl=true;sslTrustStore=/app/bds/cloudera_truststore.jks;sslTrustPassword=;principal=hive/_HOST@BDS.XXXX.COM
  
  INSERT OVERWRITE DIRECTORY &quot;/dev/ref/HIVE_EXPORT/&quot; ROW FORMAT DELIMITED FIELDS TERMINATED BY &quot;,&quot; ESCAPED BY &quot;\\&quot; SELECT * FROM test_ref_st.Daily_report  limit 10;
  
  hadoop fs -get('/dev/ref/HIVE_EXPORT/000000_0', '/user/rj/hiveExtract.csv')
  echo &quot;Query result extracted &quot;
  </code></pre>
  <p>I need to run all above steps in sequence via a shell script test1.sh like</p>
  <pre class="lang-sh prettyprint-override"><code>bash-4.2$ sh -x test1.sh
  </code></pre>
  <p>then it is only running till beeline and remaining commands are not being run.
  Current output:</p>
  <pre class="lang-sh prettyprint-override"><code>bash-4.2$ sh test1.sh
  
  Picked up JAVA_TOOL_OPTIONS:
  Beeline version 1.1.0-cdh5.16.2 by Apache Hive
  beeline&gt;
  </code></pre>