getting thousand of permissions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting thousand of permissions
# 1  
Old 12-20-2007
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
# 2  
Old 12-20-2007
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
# 3  
Old 12-20-2007
Code:
#! /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

# 4  
Old 12-20-2007
if you have stat in your system (AIX?)
Code:
# stat -c "%a:%n" *

if you have GNU find
Code:
# find  /path -printf "%m:%p\n"

# 5  
Old 12-20-2007
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.
# 6  
Old 12-20-2007
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.
# 7  
Old 12-20-2007
Code:
#!/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]
}
'

Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Concatenate several thousand files in unix

Hello, I would like to concatenate several thousand files (~40,000) into 1. I cannot do it with cat *.extension - it gives me an error that there are too many arguments. Any suggestions? Thanks, Gussi (6 Replies)
Discussion started by: Gussifinknottle
6 Replies

2. Linux

Try thousand times could not resolve famous ORA-12514 error

It is related to Linux, Oracle 9.2.0. I am new to Oracle. I am trying to connect to Oracle database say A, but as I am running this command dbstart the error is “ORA-12514: TNS: listener could not resolve SERVICE_NAME given in connect descriptor” I have successfully started lsnrctl. Here... (3 Replies)
Discussion started by: yajneshilu
3 Replies

3. Shell Programming and Scripting

removing thousand of carriage returns using sed

I need to replace thousands of carriage returns/line breaks in a large xml file and with spaces. I hope to do so with a script, called, for example, "removeCRs." I would invoke this at the command line as ml5003$ sed -f /Users/ml5003/removeCRs oldFile > newFile The script, I presume, would... (4 Replies)
Discussion started by: ml5003
4 Replies

4. What is on Your Mind?

65 thousand dollar question

I was just a-wondering through some hardware and software sites, and in one of them, I was scrolling down a UNIX os page when I noticed that the prices for these OS's were climbing alarmingly high; in the 5 to 10 G's. Imagine my surprise when I saw one particular UNIX os selling for 65 freakin'... (10 Replies)
Discussion started by: mud
10 Replies
Login or Register to Ask a Question