LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2008, 02:36 PM   #1
cmontr
Member
 
Registered: Sep 2007
Posts: 175

Rep: Reputation: 15
shell script to print ldap users


Hello guys,

Could someone tell me why the code below doesn't print? I tried modifying few times but getting the same result. It is supposed to read data from a backup file, run ldapsearch, print all needed IDs defined in the ldapsearch. Somehow it prints 0, though ldapsearch in my sample ldif file works fine. It is Solaris machine.

Any help appreciated

----------------------
code:

#!/bin/ksh
while read g
do
echo ""
ldapsearch -L -h localhost -p 5555 -D "uid=sm_admin,ou=abc_admin,o=abc.com" -w sm_passwd -b o=vz.com -s sub uid=$g
done < g.ldif > g_out.txt

------------------------

input file (g.ldif):

dn: uid=testID,ou=abc,o=abc.com
objectclass: top
objectclass: someuser
uid: testID
 
Old 08-19-2008, 02:26 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
What do expect/want the script to do?
I can't figure out from the script what it is supposed to do.
 
Old 08-19-2008, 10:36 AM   #3
cmontr
Member
 
Registered: Sep 2007
Posts: 175

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Hko View Post
What do expect/want the script to do?
I can't figure out from the script what it is supposed to do.
It is supposed to run ldapsearch in the loop and read data from backup ldif file and print all user ids. I will be able to modify the ldapsearch with the correct attributes. Just want to make this one working for now as sample. Thanks for the reply.
 
Old 08-19-2008, 01:43 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by cmontr View Post
It is supposed to run ldapsearch in the loop and read data from backup ldif file and print all user ids. I will be able to modify the ldapsearch with the correct attributes. Just want to make this one working for now as sample.
OK, something like this?
(note: this is bash, I don't know ksh, zo you may need too adapt it a little to ksh)
Code:
#!/bin/bash

sed -n 's/^uid: //p' g.ldif | while read g
do
echo ""
#ldapsearch -L -h localhost -p 5555 -D "uid=sm_admin,ou=abc_admin,o=abc.com" -w sm_passwd -b o=vz.com -s sub uid=$g >>g_out.txt
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu bashed shell script for users shell 0.o Linux - Server 6 02-14-2013 06:00 AM
how to print an apostrophe (') in a shell script using awk? skuz_ball Programming 11 03-10-2012 08:26 AM
script for adding users information in ldap database aravind1024004 Linux - Server 1 07-16-2008 06:39 AM
How to print my process id using shell script ik_nitk Programming 4 06-07-2007 12:23 AM
Trying to write a perl script that will print shell variable ohcarol Programming 2 04-16-2007 08:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration