Sponsored Content
Full Discussion: if condition issue
Top Forums Shell Programming and Scripting if condition issue Post 302610627 by svajhala on Wednesday 21st of March 2012 01:26:57 PM
Old 03-21-2012
if condition issue

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

Code:
#!/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

Code:
./CreateRoles.ksh[42]: syntax error at line 71 : `else' unexpected

Thanks,
Sri
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

An issue with condition statement in shell script

Hello forum members. please go through the below mentioned issue and let me know the right solution. I have to write a script which runs another script .the executable script take input parmeters.so iam writing the the script below . Sample Code:Begins #! /bin/ksh echo " enter... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

2. UNIX for Dummies Questions & Answers

If condition issue

Hello, I am using the following code #!/bin/sh chris='rerun' chris2=$1 echo "chris=$chris" echo "chris2=$chris2" if then echo "RERUN" else echo "NOT RERUN" fi (6 Replies)
Discussion started by: chriss_58
6 Replies

3. Shell Programming and Scripting

if condition issue

Hi, Unix Gurus, I got some issue with my script. #!/usr/bin/ksh while read newstatus do if ; then echo "It is finished " else echo "Not Finished" fi done <checkresult.txt basically, I want to read one file (the file only contains one word, but it dynamically changed),... (2 Replies)
Discussion started by: ken002
2 Replies

4. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

5. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

6. Shell Programming and Scripting

Condition checking issue while if

hi, i am using a simple condition end_ct=`sqlplus -s $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << EOF select description from bravo_statistics where trunc(time_stamp)=trunc(sysdate)-1 and description='END CAT'; EOF` echo $end_ct; echo... (30 Replies)
Discussion started by: lovelysethii
30 Replies

7. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

8. Shell Programming and Scripting

Issue with IF condition

Getting syntax error when the condition after -o returns more than one file if then echo "Found" fi output: =>ls -l total 5 -rw-rw-r-- 1 wes wes 0 Jun 25 04:51 a.done -rw-rw-r-- 1 wes wes 0 Jun 25 04:51 a.zip -rw-rw-r-- 1 wes wes ... (13 Replies)
Discussion started by: anijan
13 Replies

9. Shell Programming and Scripting

Solaris 11 ksh93 if condition issue

Solaris 11 ksh93 if condition issue Has anyone run into issues with Solaris 11 with ksh93 if condition where it intermittently return wrong return code? We did not see this issue in Solaris 10 with ksh88 Any thoughts? Thanks! Solaris version: SunOS t52-ccc-28 5.11 11.2... (4 Replies)
Discussion started by: nugent
4 Replies

10. Shell Programming and Scripting

Issue with condition "if then elif else fi"

Hi everybody, I must get trought a shell script 3 arguments. 1st argument = $1 (can take values REP1..4) 2nd argument = $2 (can take values A..Z) 3rd arguement = $3 (also can take values A...Z) I've written this code : #!/bin/bash if then liste=/data/folder1 echo... (6 Replies)
Discussion started by: shellX
6 Replies
roles(1)							   User Commands							  roles(1)

NAME
roles - print roles granted to a user SYNOPSIS
roles [ user ...] DESCRIPTION
The command roles prints on standard output the roles that you or the optionally-specified user have been granted. Roles are special accounts that correspond to a functional responsibility rather than to an actual person (referred to as a normal user). Each user may have zero or more roles. Roles have most of the attributes of normal users and are identified like normal users in passwd(4) and shadow(4). Each role must have an entry in the user_attr(4) file that identifies it as a role. Roles can have their own authorizations and profiles. See auths(1) and profiles(1). Roles are not allowed to log into a system as a primary user. Instead, a user must log in as him-- or herself and assume the role. The actions of a role are attributable to the normal user. When auditing is enabled, the audited events of the role contain the audit ID of the original user who assumed the role. A role may not assume itself or any other role. Roles are not hierarchical. However, rights profiles (see prof_attr(4)) are hierarchical and can be used to achieve the same effect as hierarchical roles. Roles must have valid passwords and one of the shells that interprets profiles: either pfcsh, pfksh, or pfsh. See pfexec(1). Role assumption may be performed using su(1M), rlogin(1), or some other service that supports the PAM_RUSER variable. Successful assumption requires knowledge of the role's password and membership in the role. Role assignments are specified in user_attr(4). EXAMPLES
Example 1: Sample output The output of the roles command has the following form: example% roles tester01 tester02 tester01 : admin tester02 : secadmin, root example% EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 An error occurred. FILES
/etc/user_attr /etc/security/auth_attr /etc/security/prof_attr ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
auths(1), pfexec(1), profiles(1), rlogin(1), su(1M), getauusernam(3BSM), auth_attr(4), passwd(4), prof_attr(4), shadow(4), user_attr(4), attributes(5) SunOS 5.10 14 Feb 2001 roles(1)
All times are GMT -4. The time now is 03:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy