home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / perl / get-cf < prev    next >
Text File  |  1992-03-10  |  2KB  |  74 lines

  1. #! /usr/local/bin/perl
  2.  
  3. @dot_files = (
  4.     ".login", ".logout", ".cshrc",            # csh, cshe or tcsh
  5.     ".profile",                        # ksh, sh
  6.     ".env",                        # ksh
  7.     ".alias", ".aliases",                # common for all shells
  8.     "user.ps", ".user.ps", "tools.ps", ".tools.ps",
  9.     "startup.ps", ".startup.ps",            # NeWS
  10.     ".mgrc",                        # MGR
  11.     ".X11init", ".awmrc", ".twmrc", ".xinitrc",        # X11
  12.     ".emacs"                        # emacs
  13. );
  14.  
  15. %seen = {};
  16.  
  17. open(HOST, "/bin/hostname |") || die "can't get the hostname";
  18. chop($hostname=<HOST>);
  19. close(HOST);
  20.  
  21. user_loop:
  22.     for (($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwent();
  23.          $name ne "";
  24.          ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwent()) {
  25.  
  26.     #
  27.     # If the user has a home directory on this server, get the info 
  28.     # about the directory, his CF's and so on.
  29.     #
  30.     if ($dir =~ m,^/n/$hostname/,) {
  31.         if (! -d $dir) {
  32.         printf(stderr "home directory '%s' for user '%s' doesn't exist.\n",
  33.             $dir,
  34.             $name);
  35.         next user_loop;
  36.         }
  37.  
  38.         ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
  39.                     $atime,$mtime,$ctime,$blksize,$blocks)
  40.                         = stat(_);
  41.         $mode = $mode & 07777;
  42.  
  43.         &spit_it_out("d", $uid, $gid, $mode, $dir);
  44.  
  45.         foreach $file (@dot_files) {
  46.         $path = "$dir/$file";
  47.  
  48.         if (-f $path) {
  49.             ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
  50.                         $atime,$mtime,$ctime,$blksize,$blocks)
  51.                             = stat(_);
  52.             $mode = $mode & 07777;
  53.  
  54.             &spit_it_out("f", $uid, $gid, $mode, $dir);
  55.         }
  56.         }
  57.     }
  58.     }
  59.  
  60.  
  61.  
  62.  
  63. sub spit_it_out {
  64.     local($type, $uid, $gid, $mode, $name) = @_;
  65.  
  66.     if (defined($seen{$name})) {
  67.     return;
  68.     }
  69.  
  70.     printf("%s %d %d 0%o %s\n", $type, $uid, $gid, $mode, $name);
  71.     $seen{$name} = 1;
  72. }
  73.  
  74.