Perl has the getpwent function from C. You can use that directly as a perl function if you want. You might need the stat function. Also linux has the pwck tool that identifies some of the problems you describe. It's just as fine to do it the way you're going. /etc/passwd is very parseable as text, another way to do it.

If you run the program as root, your program has all the permissions as root. So if you make a mistake in your programming and accidentally tell perl to wipe out your password file, the OS is not going to stop it from doing that, it is allowed. If your program runs with more limited permissions, the OS will prevent it from doing things it is not allowed to do.

Perl has more to offer in this venture also. You could make your program aggregate the results into an excel spreadsheet, e-mail you the results, fix them right there, etc. To actually fix the results you would probably need more permissions.


In reply to Re: List users without homes and homes without users by trippledubs
in thread List users without homes and homes without users by codeout

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.