My shell script is failing with syntax error for the function with a simple if statement in it. Not sure what I am missing in the below code:
#!/bin/ksh
if [ $# -ne 1 ]; then
echo Param: [ENV]
exit 1
fi
ENV=$1
if [ $ENV == "qa" ]
then
HDFS_LOCATION="QA" && HIVE_DB="qa"
else
HDFS_LOCATION="prod" && HIVE_DB="prod"
fi
if [ $ENV == "prod" ]
then
ISILON="isilonprod"
else
ISILON="isilondev"
fi
check() {
if [$1 -ne 0]; then
echo "----------------------Error-------------------"
exit 1
else
echo "----------------------------------------------"
echo "----------------------Done--------------------"
echo "----------------------------------------------"
fi
}
echo "#################### CREATE TABLES IN HIVE ##################################"
hconnect -f --hivevar hdfs_location=${HDFS_LOCATION} --hivevar isilon=${ISILON} /tmp/nanda/deployment/poc_src_dallas_al.hql
check $?
echo "#################### END HIVE ONLY TABLES ##################################"
ERROR:
[root@myhost deployment]# sh deploy.ksh qa
'eploy.ksh: line 22: syntax error near unexpected token `{
'eploy.ksh: line 22: `check() {