title: "Beeline command not found" error while executing beeline command from python script (called from oozie shell action)
body: <p>I have a python script that I want to schedule using oozie. I am using Oozie shell action for invoking the script. There is a beeline command in the script. When I run the oozie workflow, I get error <strong>"sh: beeline: command not found"</strong>. If I run this script or just the beeline command manually from edge node, it runs perfectly fine. My data platform is Hortonworks 2.6. Below is my workflow.xml and python script:</p>
  
  <p><strong><em>Workflow.xml</em></strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;workflow-app xmlns="uri:oozie:workflow:0.3" name="hive2-wf"&gt;
      &lt;credentials&gt;
          &lt;credential name='hcat-creds' type='hcat'&gt;
              &lt;property&gt;
                  &lt;name&gt;hcat.metastore.uri&lt;/name&gt;
                  &lt;value&gt;thrift://host:9083&lt;/value&gt;
              &lt;/property&gt;
              &lt;property&gt;
                  &lt;name&gt;hcat.metastore.principal&lt;/name&gt;
                  &lt;value&gt;hive/_HOST@SOLON.PRD&lt;/value&gt;
              &lt;/property&gt;
             &lt;/credential&gt;
      &lt;/credentials&gt;
      &lt;start to="python-node"/&gt;
      &lt;action name="python-node" cred="hcat-creds"&gt;
          &lt;shell xmlns="uri:oozie:shell-action:0.1"&gt;
              &lt;job-tracker&gt;${jobTracker}&lt;/job-tracker&gt;
              &lt;name-node&gt;${nameNode}&lt;/name-node&gt;
              &lt;exec&gt;run_validations.py&lt;/exec&gt;
              &lt;argument&gt;--jdbcURL&lt;/argument&gt;&lt;argument&gt;${jdbcURL}&lt;/argument&gt;
              &lt;argument&gt;--jdbcPrincipal&lt;/argument&gt;&lt;argument&gt;${jdbcPrincipal}&lt;/argument&gt; 
                          &lt;env-var&gt;PYTHONPATH=/bin/python&lt;/env-var&gt;
              &lt;env-var&gt;PYTHON_EGG_CACHE=/tmp&lt;/env-var&gt;
                          &lt;env-var&gt;PATH=/usr/bin&lt;/env-var&gt;
              &lt;env-var&gt;HADOOP_CLASSPATH=${HADOOP_CLASSPATH}&lt;/env-var&gt;
              &lt;file&gt;run_validations.py&lt;/file&gt;
          &lt;/shell&gt;
          &lt;ok to="end"/&gt;
          &lt;error to="fail"/&gt;
      &lt;/action&gt;
      &lt;kill name="fail"&gt;
          &lt;message&gt;Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]&lt;/message&gt;
      &lt;/kill&gt;
      &lt;end name="end"/&gt;
  &lt;/workflow-app&gt;
  </code></pre>
  
  <p><strong><em>Script:</em></strong></p>
  
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python2
  
  import sys, os, commands, datetime, time ,getpass, errno
  from optparse import OptionParser
  import subprocess
  from subprocess import Popen, PIPE
  
  def arg_handle():
      usage = "usage: run_validations.py [options]"
      parser = OptionParser(usage)
      parser.add_option("-u", "--jdbcURL",dest="jdbcURL",help="jdbcURL")
      parser.add_option("-p", "--jdbcPrincipal",dest="jdbcPrincipal",help="jdbcPrincipal") 
  
      (options, args) = parser.parse_args()
      print("run_validations.py  -&gt; Input      : " + str(options))
      return options
  
  def main():
      print("run_validations.py  -&gt; Started Run_validations.py")
      options = arg_handle()
  
      print("JDBC URL : "+options.jdbcURL)
      print("JDBC PRINCIPAL : "+options.jdbcPrincipal)
  
      beeline_connection = options.jdbcURL+";principal="+options.jdbcPrincipal
      hive_cmd = 'beeline -u "'+beeline_connection+'" -e "select 1+2;"'
      print("Invoked :"+hive_cmd)
      rc,out =  commands.getstatusoutput(hive_cmd)
      if(rc==0):
          print("RC : "+str(rc))
          print("Output :")
          print(out)
      else:
          print("RC : "+str(rc))
          print("Output :")
          print(out)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p><strong><em>Output</em></strong></p>
  
  <pre><code>&gt;&gt;&gt; Invoking Shell command line now &gt;&gt;
  
  Stdoutput run_validations.py  -&gt; Started Run_validations.py
  Stdoutput run_validations.py  -&gt; Input      : {'jdbcURL': 'jdbc:hive2://host:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2', 'jdbcPrincipal': 'hive/_HOST@SOLON.PRD'}
  Stdoutput Invoked :beeline -u "jdbc:hive2://host:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;principal=hive/_HOST@SOLON.PRD" -e "select 1+2;"
  Stdoutput RC : 32512
  Stdoutput Output :
  Stdoutput sh: beeline: command not found
  Exit code of the Shell command 0
  &lt;&lt;&lt; Invocation of Shell command completed &lt;&lt;&lt;
  </code></pre>
  
  <p>Could someone please tell me what it is that I am missing?</p>