getting thousand of permissions

Hi, I would like to ask if someone could help me to shorten this process.
If example i will have a thousand files and i want to get there permisions. pls help.

$ sh researcher2.sh
rm /home/aris/logs/logna
rm a12
for i in `aclget /usr/bin/uname`
do
grep -e $i ownership | awk '{print $1}'
done > a12
echo /usr/bin/uname has the permission of `cat a12` > /home/aris/logs/logna

rm a12
for i in `aclget profile`
do
grep -e $i ownership | awk '{print $1}'
done >> a12
echo profile has the permission of `cat a12` >> /home/aris/logs/logna

rm12
for i in `aclget cron.sh`
do
grep -e $i ownership | awk '{print $1}'
done >> a12
echo cron.sh has the permission of `cat a12` >> /home/aris/logs/logna

clear
cp logna /home/aris/a/orig
cat /home/aris/logs/logna

this is the output :

/usr/bin/uname has the permission of 5 5 5
profile has the permission of 1
cron.sh has the permission of 1 7 7 7
------------------------------------------------------------------------i already tried this one, but it didnt work

y=`cat test`
for x in `aclget $y`
do
grep -e $x ownership | awk '{print $1}' >> file122
echo $y permisions is `cat file122` >> file1
done
cat file1

$ cat test
/usr/bin/uname
profile
cron.sh

This is the value of ownership if you may ask.

$ cat ownership
1 --x
2 -w-
3 -wx
4 r--
5 r-x
6 rw-
7 rwx

#! /usr/local/bin/perl

open(DATA, "< test") || die "Unable to open file test\n";
while (<DATA>) {
        chomp;
        printf  "%s has permission %o \n", $_ , (stat($_))[2]& 0777;
}
close(DATA);
exit 0

if you have stat in your system (AIX?)

# stat -c "%a:%n" *      

if you have GNU find

# find  /path -printf "%m:%p\n"

sir's,
thanks for the support, but only perl works w/ me. Currently there is no stat command in my aix. I really thank Sir Perderabo.

It is much better if it is purely shell script, no problem w/ perl,but this script will be the script to all of our servers. We know that diffrnt servers diffrnt perl.

perl does vary quite a bit between versions and this can cause portability problems. But I doubt that you will be able to find any perl version which cannot run that little script. It stays with just a few basic things. And you wanted speed. There is no way to come close to the performance of the perl script with a shell script.

#!/bin/sh
# assume no setuid,setgid bits set.
ls -l | awk '
BEGIN{
perm["rwx"]=7
perm["rw-"]=6
perm["r--"]=4
perm["-wx"]=3
perm["--x"]=1
perm["r-x"]=5
pern["-w-"]=2
}
{
 uperm = substr($1,2,3)
 gperm = substr($1,5,3)
 operm = substr($1,8,3) 
 printf "%s has permission: %s%s%s\n", $9,perm[uperm],perm[gperm],perm[operm]
}
'

Sir Ghost,
I thank you for your kindness. Are you a shell programmer? what is your job? Anyway, this is the output that i wanted.

/var/adm/cron/at.allow has the permission 0
/var/adm/cron/cron.allow has the permission 0
/usr/bin/uname has the permission 555
/usr/bin has the permission 755
/dev/mem has the permission 440

$ cat test
/var/adm/cron/at.allow
/var/adm/cron/cron.allow
/usr/bin/uname
/usr/bin
/dev/mem

while read line 
do
    ls -l $line | awk '
    BEGIN{
    perm["rwx"]=7
    perm["rw-"]=6
    perm["r--"]=4
    perm["-wx"]=3
    perm["--x"]=1
    perm["r-x"]=5
    pern["-w-"]=2
    }
    {
    uperm = substr($1,2,3)
    gperm = substr($1,5,3)
    operm = substr($1,8,3) 
    printf "%s has permission: %s%s%s\n", $9,perm[uperm],perm[gperm],perm[operm]
    }
    '
done < test

stil got no exact results..
this is the result of the said script :frowning:

users has permission: 555
usrck has permission: 5
utftp has permission: 55
uucp has permission: 55
uudecode has permission: 555
uuencode has permission: 555
uulog has permission: 555
uuname has permission: 55
uupick has permission: 555
uupoll has permission: 555
uuq has permission: 55
uusend has permission: 555
uusnap has permission: 55
uustat has permission: 55
uuto has permission: 555
uux has permission: 55
vacation has permission: 555
val has permission: 555
vc has permission: 555
vedit has permission: 555
vgrind has permission: 755
vi has permission: 555
view has permission: 555
vmh has permission: 555
vmstat has permission: 55
vmstat64 has permission: 55
w has permission: 55
w64 has permission: 55
wait has permission: 555
wallevent has permission: 777
wc has permission: 555
what has permission: 555
whatis has permission: 555
whatnow has permission: 555
whereis has permission: 555
which has permission: 555
who has permission: 555
whoami has permission: 555
whois has permission: 555
whom has permission: 555
wlmmon has permission: 777
write has permission: 555
wsm has permission: 777
xargs has permission: 555
xget has permission: 555
xmodem has permission: 555
xmwlm has permission: 755
xsend has permission: 555
yacc has permission: 777
yes has permission: 555
ypcat has permission: 555
ypmatch has permission: 555
yppasswd has permission: 55
ypservers has permission: 555
ypwhich has permission: 555
zcat has permission: 555
zcmp has permission: 777
zgrep has permission: 777
zmore has permission: 777
znew has permission: 777
2005 has permission: 44

i have left out perm["---"] , you can add it in to represent 0.

sir this is the content of my file name test.

$ cat test
/var/adm/cron/at.allow
/var/adm/cron/cron.allow
/usr/bin/uname
/usr/bin
/dev/mem
/etc/hosts.equiv
/var/adm/sulog
/etc/security/failedlogin
/var/adm/wtmp
/etc/security/lastlog
$

this is the output that i wanted to achieve :

/var/adm/cron/at.allow has the permission 0
/var/adm/cron/cron.allow has the permission 0
/usr/bin/uname has the permission 555
/usr/bin has the permission 755
/dev/mem has the permission 440
/etc/hosts.equiv has the permission 644
/var/adm/sulog has the permission 600
/etc/security/failedlogin has the permission 0
/var/adm/wtmp has the permission 644
/etc/security/lastlog has the permission 0
$

use the perl script then, if you still can't get the results.

yeah i know..thanks, thanks for those who reply.