Forum: Ruby Searching a string in a line

Posted by Fosiul Alam (fosiul)
on 2012-08-05 16:00
Hi
I would be really greatfull if any one can give me some lights on my
bellow query .

I want to run a query like this

subject= system" ldapsearch -xZZ -D cn=Directory Managerl -w 'testtest'
-b 'ou=groups,l=uk,dc=fosiul,dc=lan'  cn=ops-uk"

now it should return a output like this

# extended LDIF
#
# LDAPv3
# base <ou=groups,l=uk,dc=fosiul,dc=lan> with scope subtree
# filter: cn=techops-uk
# requesting: ALL
#

# techops-uk, groups, UK, fosiul.lan
dn: cn=ops-uk,ou=groups,l=UK,dc=fosiul,dc=lan
gidNumber: 6000
objectClass: top
objectClass: groupofuniquenames
objectClass: posixgroup

cn: hops-uk

# search result
search: 3
result: 0 Success

# numResponses: 2
# numEntries: 1

Now i just need to grab this line

gidNumber: 6000    to get just 6000

actually 6000

but dont understand.. how to do that
Can any one please help me with this

Thanks for your help.
Fosiul
Posted by Jan E. (jacques1)
on 2012-08-05 21:52
Hi,

Use a regular expression:

p subject[/^gidNumber: (\d+)/, 1]
Posted by Fosiul Alam (fosiul)
on 2012-08-06 00:55
Hi
thanks thats great .
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.