Find_ldap_server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find_ldap_server
# 1  
Old 04-24-2014
Find_ldap_server

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.
5. Do i have to declare 2 separate variables like the "$LDAP_Server" ?
#!/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

Last edited by amarlinux; 04-24-2014 at 10:10 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question