codeout has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to develop a Perl script to look for orphaned homes (home directories without users, or the inverse). This script should generate a formatted listing of any user without a home directory... ...or any home directory (a directory in /home) that is not attached to a user. The identifying element is the UID, not the username. I need to understand the difference between running the program as root as well as running it without root privileges
I'm using file handles to grab information from the OS about homes and users -- and put that information into arrays. The script would essentially be running external shell processes and reading from those processes' output just like reading from a text file. This code, will be executed on a standard Linux OS.
Array for the usersArray for the homesopen (USERS, '-|' , 'getent passwd' ) or die $!; @passwd_entries = <USERS>;
open (HOMES, '-|' , 'ls /home' ) or die $!; @home_dirs = <HOMES>; close HOMES;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: List users without homes and homes without users
by poj (Abbot) on May 16, 2018 at 18:38 UTC | |
Re: List users without homes and homes without users
by trippledubs (Deacon) on May 16, 2018 at 18:27 UTC | |
Re: List users without homes and homes without users
by Anonymous Monk on May 16, 2018 at 18:31 UTC |