tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: "Spalding, Stephen" <SSpaldin () mem-ins ! com>
To: tru64-unix-managers
Subject: SUMMARY: Permissions on a file
Date: Tue, 09 Jun 1998 19:34:32 +0000	[thread overview]
Message-ID: <96078712011552.tru64-unix-managers.marc@archive.invalid> (raw)

Since I posted my message a few minutes ago, I got one response which has to
do with using c language to write a short 
program. Here it is:

> the stat() lstat() and fstat() functions are keen to this.  If I had the
> time and skill I would try to program a c app for this purpose.  You
> might want to try this yourself if you are handy with c.
> 
> Nathan J Grass, MV-STAR Technical Support
> Utility Translation Systems, Inc. Raleigh, NC
> 919 876 2600 x2216   Fax: 919.876.4001
> nathang@uts.itron.com / zaz@null.net
> 
> 
> 
Unfortunately, I am not handy with c. I wrote a small, simple ksh script to
take care of the problem. Again, it's very simple and would need to be
modified to take care of extra permissions (sticky bit and so forth) and
would not work on files which the user does not have permission, but on
simple files it should do just fine. Here is my script:

#!/bin/ksh
file=$1

perms=`ls -l $file|awk '{print $1}'`

x=2
count1=0
count2=0
count3=0

while [ $x != 11 ]; do
        letter=`echo $perms|cut -b $x`
        case $x in
                [2-4])  case $letter in
                                r)      let count1=count1+4
                                        ;;
                                w)      let count1=count1+2
                                        ;;
                                x)      let count1=count1+1
                                        ;;
                        esac    #case $letter in
                        ;;
                [5-7])  case $letter in 
                                r)      let count2=count2+4
                                        ;;
                                w)      let count2=count2+2
                                        ;;
                                x)      let count2=count2+1
                                        ;;
                        esac    #case $letter in
                        ;;
                [8-9]|10)       case $letter in 
                                        r)      let count3=count3+4
                                                ;;
                                        w)      let count3=count3+2
                                                ;;
                                        x)      let count3=count3+1
                                                ;;
                                esac    #case $letter in

                        ;;
        esac    #case $x in
        let x=x+1
done

echo "The permissions are $count1$count2$count3 "



- Stephen Spalding

             reply	other threads:[~1998-06-09 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-09 19:34 Spalding, Stephen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-06-09 20:59 SUMMARY: Permissions on a file Peter Olson, Delphi Information Engineer
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox