The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Linux Shell Question: how to print the shell script name ? meili100 UNIX for Dummies Questions & Answers 3 07-01-2008 01:55 PM
shell script to print '*' triangle akash Shell Programming and Scripting 12 01-10-2008 12:18 AM
shell script help for users cmontr Shell Programming and Scripting 9 11-15-2007 10:17 AM
link LDAP-Users funksen UNIX for Advanced & Expert Users 3 02-19-2007 01:13 PM
Equivalent of ADMCHG for LDAP Users vipas UNIX for Advanced & Expert Users 0 12-16-2004 12:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-18-2008
cmontr cmontr is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 22
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
  #2 (permalink)  
Old 08-18-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
That script will run ldapsearch 4 times, once for each line in your g.ldif file. Any spaces etc in the input file will be treated as new commandline arguements to ldapsearch.

What's the commandline you use when it works fine?
  #3 (permalink)  
Old 08-19-2008
cmontr cmontr is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 22
Quote:
Originally Posted by Smiling Dragon View Post
That script will run ldapsearch 4 times, once for each line in your g.ldif file. Any spaces etc in the input file will be treated as new commandline arguements to ldapsearch.

What's the commandline you use when it works fine?
Hi -

If you just run the ldapsearch for a single user id as;

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=xyz

It will work and print the ID info.

But what I want is to put this in a loop that will run thru the backup ldif file and print all user ids as specified in the ldapsearch.

Any help is appreciated.
  #4 (permalink)  
Old 08-19-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
what result you are looking for ?

- nilesh
  #5 (permalink)  
Old 08-19-2008
cmontr cmontr is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 22
Quote:
Originally Posted by ynilesh View Post
what result you are looking for ?

- nilesh
Hi -

For example, the output could be the all dn value or just the uids:

such as:

dn: uid=testID1,ou=abc,o=abc.com
dn: uid=testID2,ou=abc,o=abc.com
dn: uid=testID3,ou=abc,o=abc.com
dn: uid=testID4,ou=abc,o=abc.com

or:

testID1
testID2
testID3
testID4

etc...

It should loop through the big backup file, 15+GB and print the values. Then I need to be able to FTP those. That will be automated and I am working on it. Hopefully I will resolve this why it isn't printing.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0