Assistance with Folder Permissions on a User's Desktop

michaelmcgaw
New Contributor III

I want to run a script on a Mac that is initiated by an item in Self Service.

Our user accounts are AD based, "Managed" and "Mobile" according to Users & Groups.

The script is going to create a folder on the user's desktop and then copy some log files to the folder.

I want the user to be be able to review the contents of the folder but, as created by the script, the user does not have permission to do so.

So: after the folder is created and populated, how do I chmod the folder so that it belongs to the user account? I'm able to get the userID and set it as the folder owner, but I have no idea what group to assign. Just changing the owner of the folder doesn't appear to give the user access to it. I'm doing something wrong, I just can't figure out what that is.

Can anyone offer some direction?

1 ACCEPTED SOLUTION

ryan_ball
Valued Contributor

This should do it:

#!/bin/bash

userName=""
folder="/Users/$userName/Desktop/FolderName"

chown -R "$userName" "$folderName"

exit 0

View solution in original post

3 REPLIES 3

ryan_ball
Valued Contributor

This should do it:

#!/bin/bash

userName=""
folder="/Users/$userName/Desktop/FolderName"

chown -R "$userName" "$folderName"

exit 0

ryan_ball
Valued Contributor

If that does not work you can throw this at the end:

chmod 700 "$folderName"

michaelmcgaw
New Contributor III

@ryan.ball thank you! It was the -R on the chown that did the trick!