From owner-freebsd-questions@FreeBSD.ORG Mon Mar 22 12:24:31 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A208106564A for ; Mon, 22 Mar 2010 12:24:31 +0000 (UTC) (envelope-from sunckell@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id AE58D8FC13 for ; Mon, 22 Mar 2010 12:24:30 +0000 (UTC) Received: by bwz8 with SMTP id 8so73094bwz.3 for ; Mon, 22 Mar 2010 05:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=jDRZb3EgzcyTaoiWzfbhReyC34In8+OnhCWnZd8YR10=; b=q3tJ5G2WgC76JA2Kd3aWsmvb2B07db9JfC5xgA9QLWiqTmGj2gAkLJebVkX+sAiSNL Y6HelIZ0bENGSXm4JTTLEN7CUxrsqSpijKeix/imqF7T6phP1tM6pjNZ3RDqSJ3JGc92 OBH2vV4sH27780GDFsa4w0n8vSP9xwPDh9tA0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Vaa7YGZsfPkGwIpk6I4ZpOJ5grbk+ZezXuOsnLX/YBKPRehju+ul4CYCVjyldnne3Q jJNPjExMwLWhRT/DTaSkq3r1hxheYde3r5OcXZJUyIkfbOmb5ymT9vas75CtFpQ2F64L KDgcJcliGhZXuXT68Q1jnbDEwJPjKonyIhU08= MIME-Version: 1.0 Received: by 10.204.141.67 with SMTP id l3mr3146803bku.38.1269259363971; Mon, 22 Mar 2010 05:02:43 -0700 (PDT) In-Reply-To: <4BA75588.4090107@gmail.com> References: <4BA75588.4090107@gmail.com> Date: Mon, 22 Mar 2010 08:02:43 -0400 Message-ID: <21bb29221003220502q29634386w3e84d432136ad0dc@mail.gmail.com> From: Chad Kellerman To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: how to compare permissions between two dirs X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2010 12:24:31 -0000 On Mon, Mar 22, 2010 at 7:33 AM, Aryeh M. Friedman wrote: > In switching to a new make file for a personal project I have run into the > problem of under the old makefile everything works (web site) and under the > new one it does not... when manually looking at the two dirs they appear > identical in layout, sizes and perms (dir and file level) but I want to make > sure... is there any way to compare two diff dirs and see if they only > differ in date stamps? (note since there are several developers working on > this project I need to compare even if the owners are diff) > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" > I have done this in the past.... You can write a script that writes the 'stats' that you want about each directory to a file, then compare the two. ---------------------------------------------------- #!/usr/bin/perl use strict; use Fcntl ':mode'; use File::Find (); use Digest::MD5; use Getopt::Std; $|++; my %opts; getopts('d:l:v', \%opts); my $dirname = $opts{'d'} ? $opts{'d'} : die "Please provide a Snap Shot directory\n"; my $log = $opts{'l'} ? $opts{'l'} : "/tmp/$0.$$"; my $verbose = $opts{'v'}; # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, "$dirname"); exit; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && -f _ && process( "$uid", "$gid", "$mode", "$name"); } sub process { my ($u, $g, $m, $n) = @_; my $user = getpwuid($u); my $group = getgrgid($g); my $perms = sprintf "%04o", S_IMODE($m); my $file = $n; open FILE, $file or die "Can't open $file: $!\n"; binmode(FILE); my $md5 = Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n"; close FILE; print " $user $group $perms $md5 $n\n" if ($verbose); open LOG, ">>$log" or die "Can't open log file: $!\n"; print LOG "$user $group $perms $md5 $n\n"; close LOG; } -------------------------------------------------------------- name the above script dirSnapShot.pl and run it like so: perl dirSnapShot -d /dir1 then run it again perl dirSnapShot.pl -d /dir2 run a diff on the two log files in tmp to see the difference. Chad -- A grasshopper walks into a bar and the bartender says "Hey, we have a drink named after you." And the grasshopper says "Really, You have a drink named Murray?"