SUMMARY flatten yp/NIS tree

SUMMARY flatten yp/NIS tree

Post by Martin R.J. Cleav » Mon, 24 May 1993 06:47:34



I said:

Quote:>>I would like to be able to specify a netgroup and get a list of all the
>>machines in that netgroup - has anybody done this already ?
>>[...]

I had 3 responses, so I include them all:


Well, you could obviously write a quick perl script to do this, but in the
rare instances I want to do this I just use the NIS netgroup.byhost map and
do:
        ypcat -k netgroup.byhost | egrep '[ ,]comp[, ]|,comp$'

to get a list of the hosts in the "comp" netgroup.  A quick pipe into cut(1)
will pretty up the output for you if you'd prefer it that way.

        ypcat -k netgroup.byhost | egrep '[ ,]comp[, ]|,comp$' | cut -d. -f1

Obviously this could be translated into a shellscript or shell alias.
Please note, this can miss some special cases, like only one host in the
netgroup, but you can easily extend the regex to cover it.

-------


Here's a sed command I conned a friend into creating.
It does not recurse the tree, however.

ypmatch netgroup_name netgroup | sed -e "s:(\([^,][^,]*\),[^(][^(]*:\1 :g"
....

-------


If you can use C code instead, try

        File: /pub/netgroup.tar.z (gzip'ed)
        Host: ftp.iesd.auc.dk

It can print netgroups and do various set operations on them.

-------

Thanks to all, for what I want the top is the most useful (though how would I extend the egrep to cover just one name in the group?

        Martin.

 
 
 

1. flatten yp/NIS tree

Hi,    
I would like to be able to specify a netgroup and get a list of all the machines in that netgroup - has anybody done this already ?

        ypcat -k netgroup gives a list of machines or other netgroups, like:

                key group1 group2 group3

then

        ypmatch -k group1 netgroup gives:

                group1 (machine1.1,, ) (machine1.2,, )

and
        ypmatch -k group2 netgroup gives:

                group2 (machine2.1,, ) (machine2.2,, )

so I want to be able to say:

        ypflatten key netgroup to give:

                machine1.1 machine1.2 machine2.1 machine2.2

        and this to recurse all the way down the tree.

I would prefer if it was a shell script,

 Thanks for your help, if you could mail me your comments please, I don't
 get to look at the newsgroup very often!

--
Martin Cleaver

2. Linux on DEC Alpha

3. CDROM eject woes

4. SUMMARY: Problems with passwd map in NIS (or YP)

5. Network printing has me *stumped* ;-(

6. Reasonable nis security between Solaris & Linux (was Re: Is nis (yp) a security worry?

7. Hercules Stingray and Linux..

8. NIS, NIS+, named, yp, ...

9. Nis+ and NIS (YP) compatibility

10. NIS+ under NIS(YP) Rootmaster or just Master

11. NIS yp compat mode, participating in NIS+ hierarchy, limitations?

12. SUMMARY NIS clients with NIS+ server