Operating System - HP-UX
1755151 Members
5447 Online
108830 Solutions
New Discussion юеВ

How to change perms for read only on all directories/sub-directories ?

 
SOLVED
Go to solution
Sammy_2
Super Advisor

How to change perms for read only on all directories/sub-directories ?

All Users need access to app.log which is under several sub-directories (as seen below).

The problem is everytime the app is recycled it changes the perms on all subdirectory to 740 starting with /app/weblogic10 and users are denied access.

How can I change OTHERS perms to rx on all subdirectories starting from /app/weblogic10. ? I am thinking cron every hour but do I need to chmod 755 on each subdirectory ?

Thanks



#cd /app/weblogic10/10.3.3.0/user_projects/domains/cgsqa/servers/AdminServer/tmp/_WL_user/vip/5myxvs/war/locallogs/app.log
good judgement comes from experience and experience comes from bad judgement.
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: How to change perms for read only on all directories/sub-directories ?

Hi Sammy:

You could do:

# find /app/weblogic10 -exec chmod g+rw,o+rw {} +

Regards!

...JRF...
Sammy_2
Super Advisor

Re: How to change perms for read only on all directories/sub-directories ?

JRF,
Thannks . That may work. But , I just want the directories (not files) and I only want the subdirectories in the path below.

/app/weblogic10/10.3.3.0/user_projects/domains/cgsqa/servers/AdminServer/tmp/_WL_user/vip/5myxvs/war/locallogs/app.log

I dont want all subdirectoreis under /app/weblogic10.

Thanks

good judgement comes from experience and experience comes from bad judgement.
Ismail Azad
Esteemed Contributor

Re: How to change perms for read only on all directories/sub-directories ?

Hi,

If you want only directories use -type d with the find command. You lookin' for subdirectories appropriately use the wildcard "*". Hope info helps.

Regards
Ismail Azad
Read, read and read... Then read again until you read "between the lines".....
James R. Ferguson
Acclaimed Contributor
Solution

Re: How to change perms for read only on all directories/sub-directories ?

Hi (again):

> I just want the directories (not files) and I only want the subdirectories in the path below.

OK, I think I misunderstood. You want to alter the permissions on the file at the base of the path and all of the difrectory hierarchy:

# cat ./myfix
#!/bin/sh
MYPATH=/app/weblogic10/10.3.3.0/user_projects/domains/cgsqa/servers/AdminServer/tmp/_WL_user/vip/5myxvs/war/locallogs/app.log
while [ "${#MYPATH}" -gt 1 ]
do
echo chmod g+rw,o+rw ${MYPATH}
MYPATH=$(dirname ${MYPATH})
done

...when you are satisfied with the results that this would give, remove the 'echo'.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: How to change perms for read only on all directories/sub-directories ?

>I only want the subdirectories in the path below.

Then just pass that to JRF's find. Or cd to that directory and use "find . ...".

>JRF: find /app/weblogic10 -exec chmod g+rw,o+rw {} +

If you want to add rx, change to:
find . -type d -exec chmod go+rx {} +

>Ismail: You looking for subdirectories appropriately use the wildcard "*".

find(1) will find directories without that "*".

Sammy_2
Super Advisor

Re: How to change perms for read only on all directories/sub-directories ?

JRF,
satified with the results and also with your perfect response. For my sake, could you just tell me what this line does.

while [ "${#MYPATH}" -gt 1 ]




Thanks a bunch. A perfect 10 answer. JRF.
good judgement comes from experience and experience comes from bad judgement.
James R. Ferguson
Acclaimed Contributor

Re: How to change perms for read only on all directories/sub-directories ?

Hi (again):

> could you just tell me what this line does.

while [ "${#MYPATH}" -gt 1 ]

This begins a 'while...do' loop. The *length* of the value of MYPATH is tested to be greater than one (1). While this is true, the loop is entered. I chop away a subdirectory during each iteration and hence when I reach either a "/" or a "." I want to quit.

The manpages for 'sh-posix' under the section on parameter substitution document the length feature.

I should have generalized the script. Instead of hardcoding the path you want to operate upon, we could do:

# cat ./myfix
#!/bin/sh
MYPATH=$1
while [ "${#MYPATH}" -gt 1 ]
do
echo chmod g+rw,o+rw ${MYPATH}
MYPATH=$(dirname ${MYPATH})
done

...now run as:

# ./myfix /app/weblogic10/10.3.3.0/user_projects/domains/cgsqa/servers/AdminServer/tmp/_WL_user/vip/5myxvs/war/locallogs/app.log

Regards!

...JRF...
Sammy_2
Super Advisor

Re: How to change perms for read only on all directories/sub-directories ?

Thank you Sir for the explanation. Appreciate it. JRF
good judgement comes from experience and experience comes from bad judgement.
Sammy_2
Super Advisor

Re: How to change perms for read only on all directories/sub-directories ?

I forgot one thing.

Instead of using one path, i.e, , I want to use various paths in the script. How would I change script to do that in a loop. Since it will be run via cron, I want various path hardcoded in the file itself.
Like here, I want perms change in all these.

/usr/local/patha/pathb
/usr/local/pathc/pathd
/usr/local/pathe/pathf
good judgement comes from experience and experience comes from bad judgement.