Jump to content

Featured Replies

Posted

Hi,

I am having issue with putting a simple if then elif statement working. the script checks for ldap file in solaris system and if it finds solaris box then it looks for the correct file and then grabs the ldap server names. if the server is linux server finds the proper linux ldap file and grabs the ldap server names. Please provide some help. Thanks. Issues i am having :

 

1. If i run it as user instead of root get a permission error.

2. if the file /etc/ldap.conf file dont exist on the server i get error how to avoid that.

3. only the if portion runs on solaris and not the elif same with linux server if i reverse the if statement with linux.

4. if i make 2 if statements sepaarately for solaris and linux it works but want to combine both.

#!/bin/bash

if uname=SunOS

#check ldap_client_file

then

LDAP_Server=`cat /var/ldap/ldap_client_file | grep -i "NS_LDAP_SERVERS" | grep -v "^#"`

elif uname=Linux

#check /etc/ldap.conf

then

LDAP_Server=`cat /etc/ldap.conf | grep -i "URI" | grep -v "^#"`

else

#check /etc/nslcd.conf

LDAP_Server=`cat /etc/nslcd.conf | grep -i "URI" | grep -v "^#"`

fi

echo "$LDAP_Server"

 

On solaris: output: as root:

 

bash-3.00# ./ldap_server_find

NS_LDAP_SERVERS= server names (deleting the real server names)

 

On solaris: output: as user:

 

-bash-3.00$ ./ldap_server_find

cat: cannot open /var/ldap/ldap_client_file

 

On linux: output: no output do i have to declare a new variable ??

 

[lg298786@crpciohp01iam .scripts]$ ./ldap_server_find.sh

cat: /var/ldap/ldap_client_file: No such file or directory

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...