Date: Thu, 23 Aug 2001 06:36:55 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Odhiambo Washington <wash@wananchi.com> Cc: FBSD-Q <freebsd-questions@FreeBSD.ORG> Subject: Re: One for the script gurus Message-ID: <20010823063655.B824@hades.hell.gr> In-Reply-To: <20010822180751.C21857@ns2.wananchi.com>; from wash@wananchi.com on Wed, Aug 22, 2001 at 06:07:51PM %2B0300 References: <20010822163649.B98728@ns2.wananchi.com> <20010822144333.H91302-100000@r2d2.twowaytv.co.uk> <20010822180751.C21857@ns2.wananchi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
From: Odhiambo Washington <wash@wananchi.com> Subject: Re: One for the script gurus Date: Wed, Aug 22, 2001 at 06:07:51PM +0300 > The response was overwhelming. I am very grateful to everyone who > contributed. Now the task remains with me to decide which way forward with > all the variations in your responses. Well, I couldn't resist throwing my own Perl version of this among the followups. Here is a little Perl script that will avoid accidentally creating /nonexistent homedirs, and will use the HOME directory field from the password file instead of assuming that all your users have their HOME dir under /home or something similar. Modifying this to use STDIN for input in order to make it a filter is trivial enough that you should be able to easily do it. #!/usr/bin/perl open(PWD, "</etc/passwd") || die "can't read /etc/passwd"; LINE: while (defined($line =3D <PWD>)) { chomp $line; next LINE if ($line =3D~ m/^[\s]*#/); @uinfo =3D split /:/, $line; $user =3D $uinfo[0]; $group =3D $uinfo[3]; $home =3D $uinfo[5]; # skip /nonexistent homedirs next LINE if ($home eq "/nonexistent"); # make sure that / is not accidentally chown'ed to # something else than root:wheel next LINE if ($home eq "/"); print "mkdir -p $home ; chown ${user}:${group} $home\n"; } close PWD; -giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010823063655.B824>