Computing.Net > Forums > Programming > unix shell script

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

unix shell script

Reply to Message Icon

Original Message
Name: amir134uk
Date: May 2, 2007 at 10:39:51 Pacific
Subject: unix shell script
OS: windows xp
CPU/Ram: 512
Model/Manufacturer: dell
Comment:

I dont understand the following question, if anybody can please explain with an example, you dont have to answer it! just an explanation with an example will do. thanks.

Write a script that takes a file as an argument. The script should be able to determine what permissions the owner, group and everybody has for the file passed in. The output should be displayed similar to this.

READ WRITE EXECUTE
OWNER FRED.SMITH YES YES NO
GROUP USERS YES NO NO
EVERYBODY NO NO NO


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: May 2, 2007 at 10:47:01 Pacific
Reply: (edit)

Report Offensive Follow Up For Removal

Response Number 2
Name: ghostdog
Date: May 2, 2007 at 11:49:31 Pacific
Reply: (edit)

i made this for another guy in another forum.
its crude but it does the job.
[code]
ls -l "file" | awk 'BEGIN {
owner["r"] = "read";owner["w"] = "write";owner["x"]= "execute";owner["-"]="No"
group["r"] = "read";group["w"] = "write";group["x"]="execute";group["-"]="No"
every["r"] = "read";every["w"] = "write";every["x"]="execute";every["-"]="No"
printf "%-8s%-15s%-15s%-15s\n", "Field","READ" ,"WRITE","EXECUTE"
}
{ perm = $1; own=$3 }
END { FS=""; n = split(perm,permarray)
printf "%-8s",own
for (i=2;i<=4;i++) printf "%-15s" , owner[permarray[i]];
printf "\n%-8s" , "group"
for (i=5;i<=7;i++) printf "%-15s", group[permarray[i]];
printf "\n%-8s" , "All"
for (i=8;i<=10;i++) printf "%-15s", every[permarray[i]]; print ""
}'
[/code]



Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software