From owner-freebsd-questions Wed Nov 10 10:41:52 1999 Delivered-To: freebsd-questions@freebsd.org Received: from mail.telestream.com (mail.telestream.com [205.238.4.5]) by hub.freebsd.org (Postfix) with ESMTP id 661AB14C05 for ; Wed, 10 Nov 1999 10:41:48 -0800 (PST) (envelope-from keith@mail.telestream.com) Received: from localhost (keith@localhost) by mail.telestream.com (8.9.3/8.9.3) with ESMTP id LAA14499; Wed, 10 Nov 1999 11:45:29 -0800 Date: Wed, 10 Nov 1999 11:45:29 -0800 (PST) From: To: Michael Kennett Cc: freebsd-questions@freebsd.org Subject: Re: Testing file permissions In-Reply-To: <199911101849.CAA12198@laurasia.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ls -l|awk '{print $3 $4}' will get you the ownership to be able to test it. ls -l|awk '{print $1}' will nab the perms Or am I being an idiot and still not understanding what it is you are trying to do. :) Keith On Thu, 11 Nov 1999, Michael Kennett wrote: > > You can just test the file attributes... > > > > -d file exists and is a directory > > -e file exists > > -f file exists and is a regular file > > -r you have read permissions on the file > > -s file exists and is not empy > > -w You have write permisions on the file > > -x You have execute permissions on the file > > -O You own the file > > -G Files group IS matches yours > ^^^^^ (Note these!) > > That is not quite what I want to do. These tests (and their results) apply > to the user/group id of the process conducting the test. > > What I'd like to determine is the user/group that owns the file, and what > the three different levels of access (world/group/user) are. In other > words, rather than finding out if the *current* process can access the > file, I'd like to know (in the script) what the full mode of the access > to the file is. > > For a human, it is easy enough to read off this information from the `ls -l' > command. To emulate this is in an automated script seems to require a > reasonable amount of text processing - which strikes me as rather kludgy! > > Regards, > > Mike Kennett > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message