Hi,
I have prepared the below shell script for one of the requirement which accesses Informatica application and performs certain functions.
But for some reason, if condition fails and scripts stops abruptly with the below error. Please let me know the where the problem is
#!/bin/ksh
. ${HOME}/.profile
. ${LDAP}/.infa_env.cfg
LogFile=${LDAP_Logs_Path}/CreateInfaRoles.log
LogFile_Temp=${LDAP_Logs_Path}/CreateInfaRoles_temp.log
if [ -f ${LogFile} ]
then
LogFile_Count=`cat ${LogFile} | wc -l`
if [ ${LogFile_Count} -gt 10000 ]
then
tail -10000 ${LogFile} > ${LogFile_Temp}
rm ${LogFile}
mv ${LogFile_Temp} ${LogFile}
chmod 775 ${LogFile}
fi
fi
# Find the existing Roles
cd $INFA_HOME/isp/bin
infacmd.sh ListAllRoles -dn $INFMT_DOMAIN -un $DMN_USER -sdn $SECU_DMN_TYP -hp $GATEWAY | grep -e ML_ > $LDAP/existing_roles.out
if [ -s $LDAP/existing_roles.out ]; then
fgrep -vf existing_roles.out infa_role_info.txt > temp.txt
cd $INFA_HOME/isp/bin
while read line
do
role=`echo $line | cut -d, -f1`
rd=`echo $line | cut -d, -f2`
echo $INFA_HOME/isp/bin/infacmd.sh -dn $INFMT_DOMAIN -un $DMN_USER -sdn $SECU_DMN_TYP -hp $GATEWAY -rn $role -rd ${rd}
infacmd.sh CreateRole -dn $INFMT_DOMAIN -un $DMN_USER -sdn $SECU_DMN_TYP -hp $GATEWAY -rn $role -rd ${rd}
. ${LDAP}/AddRolePrivilege.ksh $role
done < $LDAP/temp.txt
RC=$?
if [ $RC -eq 0 ] ; then
echo "Successfully created the Inforamtica Roles" >>$LogFile
rm -f $LDAP/existing_roles.out temp.txt
else
echo "Error! while trying to create Informatica Roles." >>$LogFile
rm -f $LDAP/existing_roles.out temp.txt
exit 1
else
cd $INFA_HOME/isp/bin
while read line
do
role=`echo $line | cut -d, -f1`
rd=`echo $line | cut -d, -f2`
echo $INFA_HOME/isp/bin/infacmd.sh -dn $INFMT_DOMAIN -un $DMN_USER -sdn $SECU_DMN_TYP -hp $GATEWAY -rn $role -rd ${rd}
infacmd.sh CreateRole -dn $INFMT_DOMAIN -un $DMN_USER -sdn $SECU_DMN_TYP -hp $GATEWAY -rn $role -rd ${rd}
. ${LDAP}/AddRolePrivilege.ksh $role
done < $LDAP/infa_role_info.txt
RC=$?
if [ $RC -eq 0 ] ; then
echo "Successfully created the Inforamtica Roles" >>$LogFile
else
echo "Error! while trying to create Informatica Roles." >>$LogFile
rm -f $LDAP/existing_roles.out
exit 1
fi
fi
The script fails with the following error in line number 71
./CreateRoles.ksh[42]: syntax error at line 71 : `else' unexpected
Thanks,
Sri