[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: home directories...



> I need to write a script which will run once a night, and check each
> user's home directory for a certain file.  Does anybody know the best way
> to do this?  The only thing I can think of is to parse /etc/passwd to get
> the home dir of each user of UID > 999. Is this the correct way to do it?
> What routines should one use when parsing /etc/passwd?

If all the users' home directories are in /home, then you probably
just want something like:

  find /home -name .rhosts -print

If you really *must* parse /etc/passwd, because your system is set up
in a strange way, you could use a shell script which does something
like:

#!/bin/sh

cat /etc/passwd |
while read pwline
do
  user=`split -d: -f1 $pwline`
  home=`split -d: -f6 $pwline`
  found=`find $home -name .rhosts -print`
  if [ ! -z "$found" ]; then echo "Found for $user: $found"; fi
done

You could also write a Perl script to do the same.

HTH,

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
        Debian GNU/Linux Developer,  see http://www.debian.org/~jdg


Reply to: