diff --git a/bin/ext/version.sh b/bin/ext/version.sh index bb6449d..b6a237b 100644 --- a/bin/ext/version.sh +++ b/bin/ext/version.sh @@ -27,7 +27,7 @@ version () { # hadoop 20 or newer - skip the aux_jars option and hiveconf CLASS=org.apache.hive.common.util.HiveVersionInfo - exec $HADOOP jar $JAR $CLASS + exec $HADOOP jar $JAR $CLASS 2>> ${STDERR} } version_help () { diff --git a/bin/hive b/bin/hive index 47d99f7..4818667 100755 --- a/bin/hive +++ b/bin/hive @@ -25,6 +25,8 @@ bin=`cd "$bin"; pwd` . "$bin"/hive-config.sh +TMP_USER_DIR="/tmp/${USER}" +STDERR="${TMP_USER_DIR}/stderr" SERVICE="" HELP="" while [ $# -gt 0 ]; do @@ -193,18 +195,29 @@ if [ "$HADOOP_HOME" == "" ]; then exit 4; fi -# to avoid errors from log4j2 automatic configuration loading -export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=hive-log4j2.xml " - HADOOP=$HADOOP_HOME/bin/hadoop if [ ! -f ${HADOOP} ]; then echo "Cannot find hadoop installation: \$HADOOP_HOME or \$HADOOP_PREFIX must be set or hadoop must be in the path"; exit 4; fi +if [ ! -d ${TMP_USER_DIR} ]; then + mkdir -p ${TMP_USER_DIR} 2> /dev/null + if [ $? -ne 0 ]; then + STDERR="/dev/tty" + fi +fi + +if [ "${STDERR}" != "/dev/null" ] && [ ! -f ${STDERR} ]; then + touch ${STDERR} 2> /dev/null + if [ $? -ne 0 ]; then + STDERR="/dev/tty" + fi +fi + # Make sure we're using a compatible version of Hadoop if [ "x$HADOOP_VERSION" == "x" ]; then - HADOOP_VERSION=$($HADOOP version | awk -F"\t" '/Hadoop/ {print $0}' | cut -d' ' -f 2); + HADOOP_VERSION=$($HADOOP version 2>> ${STDERR} | awk -F"\t" '/Hadoop/ {print $0}' | cut -d' ' -f 2); fi # Save the regex to a var to workaround quoting incompatabilities @@ -253,7 +266,7 @@ HBASE_BIN=${HBASE_BIN:-"$(which hbase)"} if [[ -n $HBASE_BIN ]] ; then # exclude ZK, PB, and Guava (See HIVE-2055) # depends on HBASE-8438 (hbase-0.94.14+, hbase-0.96.1+) for `hbase mapredcp` command - for x in $($HBASE_BIN mapredcp | tr ':' '\n') ; do + for x in $($HBASE_BIN mapredcp 2>> ${STDERR} | tr ':' '\n') ; do if [[ $x == *zookeeper* || $x == *protobuf-java* || $x == *guava* ]] ; then continue fi