From owner-freebsd-questions Wed Aug 22 20:37: 5 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id BF17337B40D for ; Wed, 22 Aug 2001 20:36:43 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from hades.hell.gr (patr530-b018.otenet.gr [195.167.121.146]) by mailsrv.otenet.gr (8.11.1/8.11.1) with ESMTP id f7N3aeM06226; Thu, 23 Aug 2001 06:36:40 +0300 (EEST) Received: (from charon@localhost) by hades.hell.gr (8.11.4/8.11.4) id f7N3auE01364; Thu, 23 Aug 2001 06:36:56 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 23 Aug 2001 06:36:55 +0300 From: Giorgos Keramidas To: Odhiambo Washington Cc: FBSD-Q Subject: Re: One for the script gurus Message-ID: <20010823063655.B824@hades.hell.gr> References: <20010822163649.B98728@ns2.wananchi.com> <20010822144333.H91302-100000@r2d2.twowaytv.co.uk> <20010822180751.C21857@ns2.wananchi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.2.5i In-Reply-To: <20010822180751.C21857@ns2.wananchi.com>; from wash@wananchi.com on Wed, Aug 22, 2001 at 06:07:51PM +0300 X-PGP-Fingerprint: 3A 75 52 EB F1 58 56 0D - C5 B8 21 B6 1B 5E 4A C2 X-URL: http://students.ceid.upatras.gr/~keramida/index.html Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG From: Odhiambo Washington 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, ")) { 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