Abort the shell script if any hive sql query gets failed

view full story

http://www.unix.com – Below is my shell script from which I am trying to invoke few Hive SQL queries and the below shell script works fine. Problem Statement:- If you see my first `hive -e` block in the below shell script which contains a very long Hive SQL query. Sometimes that Hive SQL query gets failed due to certain reasons and when it gets failed it moved to second hive sql query after sleeping for 120 seconds which I don't want. Is there any way if my first `hive SQL query` gets failed due to any reasons, it should get stopped automatically at that point without executing any other hive sql query after (HowTos)