Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Why my beeline CLI commnds not working as desired in shell script?

Why my beeline CLI commnds not working as desired in shell script?

New Contributor

I have a shell script code that automates the beeline commands. The code is able to connect to the JDBC, but it sits there, it doesn't seem to execute the further codes in the shell script, ie. it doesn't truncate the table, doesn't load the data, doesn't insert. Below is the whole code::

#! /bin/bash
timestamp=$(date +%Y-%m-%d-%H:%M:%S:%N)
unix_time=$(date +%Y-%m-%d-%H:%M:%S)
beeline -u $BEELINE_PREFIX -e use next;
echo "truncating the staging table tbl1..."
beeline -u $BEELINE_PREFIX -e  "TRUNCATE TABLE next.tbl1;"
echo "Loading the data in stating table tbl1"
beeline -u $BEELINE_PREFIX -e "LOAD DATA LOCAL INPATH 'path_to/tbl1.txt' INTO TABLE next.tbl1;"
echo "Appending the data into history table tbl1.."
beeline -u $BEELINE_PREFIX -e "insert into table next.hist_tbl1 select *,'$unix_time' from next.tbl1;"
When I execute ./

I could see below output:

Connecting to 
Connected to:ApacheHive
Driver:Hive JDBC
Beeline version 1.2.1000. by ApacheHive

The code seem to only execute the veru first "beeline -u", i.e, JDBC connection only. I have noted that, When I use ctrl +c, then it goes forward, and throw below error

Error:Errorwhile processing statement: FAILED:ExecutionError,return code 1 from file:/usr/ibmpacks/current/bigsql/hive/lib/hive-hbase-handler.jar does not exist (state=08S01,code=1)

Any idea, what is the mistake?


Re: Why my beeline CLI commnds not working as desired in shell script?

@amitesh sahay

I think you might just be missing quotes around "use next;" of your first beeline command. Looks like you have the quotes correctly included on the next two though.

Don't have an account?
Coming from Hortonworks? Activate your account here