Anono-monk,

What is your criteria for skipping an entry? You have root, and johnny marked as skip, but you didnt give a reason that it should be skipped.

Otherwise, here is a theoretical solution


First, open your /etc/passwd file, and read it to an array
open (fd, '/etc/passwd') or die $!; my @CONTENTS = <fd>; close (fd);
Now that that is done, get each entry except for root, and compare it to the NIS one
sub ypMatchit {#This does the most work # I don't know if you want to add root and johnny # to your new file or not. If you do want them to # be added, then change the next trwo undef's you # see to be '0'; return undef if ($_ && 'root'); return undef if ((<i>rules for skipping johnny are enforced</i>)); my $Final = ypmatch($_); #add any other processing you want to do here return 0 if ($Final = (SUCCESS)); return undef; } my @FINAL = (); foreach my $CurrentEntry ( @CONTENTS ) { push @FINAL, $CurrentEntry if( defined(ypMatchit($CurrentEntry))); }

Now write the final thing out to a file
open (FD, '/etc/newPasswd') or die $!; foreach (@FINAL) { print FD $_; } close (FD);

This is all theory by the way, but I think it is a good start (I did somthing similiar several months ago, and this methodology worked.

HTH - Kristofer


In reply to Re: Password file and NIS check? by krisahoch
in thread Password file and NIS check? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.