Determining the owner of a folder

Alex Rice alex at mindlube.com
Wed Sep 24 19:09:00 EDT 2003


On Wednesday, September 24, 2003, at 05:32  PM, Mac Dude wrote:

>
> I'm fairly ignorant about Unix (though learning), so I'm unable to 
> figure out how to tell if the current rev user has permission to open 
> a folder.  If I understand correctly, I can get the permissions via 
> "the long folders", and from that I can see that, for instance, a 
> folder with 777 permissions can be opened by anyone, and one with 700 
> permissions can only be opened by the owner (correct?),

All correct. To be more specific 777 means read+write+execute. Octal 
values are a little weird. 7's mean permission is wide open, 5's mean 
readable+executable, 4's mean readable-only.

> but how can I tell if the current user is indeed the owner?

I'm just guessing here: because I don't see a way to do it in 
transcript. Maybe wrong.

The long folders gives you the UID of the owner in the 8th column. It's 
the numeric UID, for example 501 on my OS box. There is the transcript 
global variable $USER. But there is no way to match the UID 501 to the 
$USER. One solution would be to put shell("id") and then compare it's 
output with the UID and $USER you have already. id output looks like

uid=501(alex) gid=20(staff) groups=20(staff), 80(admin)

Or you could do what you thought of already and check the uid of owner 
of the home directory, which directory path is available in $HOME.

Alex Rice <alex at mindlube.com> | Mindlube Software | http://mindlube.com

what a waste of thumbs that are opposable
to make machines that are disposable  -Ani DiFranco




More information about the use-livecode mailing list