permission help

Hi all,

I have another problem here i was hoping i could get some help with.

everyone has been so generous with their help in the past! thanks in advance.

I have a script to change the permissions on a foldeer in the hard drives preference folder.

what i ned now is to have the permissions changed in all of the user accounts preference folders.

here is what i have so far:

property targetFolder : alias (((path to startup disk) as text) & “Library:Preferences:test:”)

tell application “Finder”
set owner privileges of targetFolder to read write
set group privileges of targetFolder to read write
set everyones privileges of targetFolder to read write
end tell

thanks again!

Hi Dave,

the easiest way to do this is using the shell command chmod

property targetFolder : (((path to startup disk) as text) & "Library:Preferences:test:")
do shell script "chmod 777 " & quoted form of POSIX path of targetFolder

hey Stefan,

thanks works like a charm.

how do i get to the individual users though?

thanks!

-david

Strange that it works, dave4242.
Does it really stick…?

My idea would be to use shell scripting (chown and chmod)
Finder scripting in changing permissions / ownerships to anything other than the space that it belongs to tends to fail (or Finder should be relaunched as root, which is not what you’d want)

As Finder is quite able to READ permissions, the issue is how to transform these Finder readings into chmod command parameters
This man page may be helpful:
http://www.perlfect.com/articles/chmod.shtml

HI all,

well with some digging i have come up with this so far:

property HardDrive : alias ((path to startup disk) as text)

set excluded to {“Shared”}

tell application “Finder”

set theList to name of items of (path to "usrs") whose name is not in excluded

set targetFolder to HardDrive & theList & ":Library:Preferences:test:" as string

do shell script "sudo chmod 777 " & quoted form of POSIX path of targetFolder	

end tell

the problem now is that it is asking for the users password.

any idea how to get around that?

thanks!

Hi Dave,

your script won’t work anyway, because you must treat each item of the variable theList separately.
There is an easier way to get the names of the users and their particular folders.
To avoid the username/password dialog add the information in the do shell script line.
Try this:

tell application "System Events" to set theList to name of users
repeat with i in theList
	tell application "System Events" to set targetFolder to quoted form of (home directory of user i & "/Library/Preferences/test/")
	do shell script "sudo chmod 777 " & targetFolder user name "adminUsername" password "¢¢¢¢¢"
end repeat

Note: this works only in Tiger, if you have Panther, omit user name “adminUsername” and
you must run the script from an admin account

Hey Stefan,

the script looks great.

when i run it from the admin account i get a password error.

I assumed that i was supposed to put my password where there were black dots, yes?

also do i need to change “adminUsername” to my admin user name?

i have tried it both ways and still get a password error.

sorry if these seem silly questions. one minute i think i know what i am doing the next i am a total idiot.

thanks!

david