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_at_uts.itron.com / zaz_at_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
Received on Tue Jun 09 1998 - 21:37:18 NZST