LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 01-06-2012, 01:48 PM   #1
s_linux
Member
 
Registered: Jul 2009
Posts: 83

Rep: Reputation: 15
ldapsearch in variable


Hello ALL,

I'm doing the ldapsearch with my script

Quote:
result=`ldapsearch -x -h 000.00.00.00 -p 389 -b ou=xxx,o=xxxx -D cn=xx,ou=xx,o=xx-LLL -w xxxxx '(cn=xxx)' telephonenumber loginDisabled`
echo "$result"
so in the output result variable is

Quote:
dn: cn=xxx,ou=xxxx,o=xxxx
telephonenumber: 123-123-1234
logindisabled: False
later in the script, I'm doing following..
Quote:
telenum=`grep telephonenumber $result | cut -d ":" -f2'
I'm not getting result from this variable, I'm getting

Quote:
grep: dn: cn=xxx,ou=xxx,o=xxxx
loginDisabled: FALSE
telephonenumber: 123-123-1234: No such file or directory
How do we get just phonenumber in telenum variable.

Regards
 
Old 01-06-2012, 02:15 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi s_linux,

Make the following modifications:

Code:
telnum=`echo $result | grep telephonenumber | cut -d " " -f3-4`
 
Old 01-06-2012, 02:56 PM   #3
s_linux
Member
 
Registered: Jul 2009
Posts: 83

Original Poster
Rep: Reputation: 15
That works. Thanks.

But I dont understand why grep did not work with cut command.

Anyways Thanks again.

Regards
 
Old 01-06-2012, 03:17 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You're welcome. Please mark the thread as solved.

That is because you are looking through a variable not a file and that is the reason I used echo $result output to be sent to grep for filtering.

Enjoy linux!!!
 
  


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
ldapsearch | ldapmodify eantoranz Linux - Software 1 01-28-2013 09:33 PM
Trouble with ldapsearch and AD rcrook89 Linux - Newbie 3 06-01-2011 07:26 PM
ldapsearch query saravana_05 Linux - Newbie 1 07-09-2009 02:06 AM
ldapsearch to csv file ralinux Linux - General 1 08-18-2008 12:34 PM
ldapsearch cmontr Programming 4 11-15-2007 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 11:56 PM.

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