change dir owner

F

Frank McCown

This has probably been answered a million times, but I can't seem to
find the answer.

How can I change the owner of a directory using a Perl command? I
know chown can be used with files, but it doesn't appear to work with
directories.

Thanks in advance,
Frank
 
F

Frank McCown

I found that you can issue a system command that works instead, but it
seems like there should be a Perl function that does the same.

system("chown username.groupname my_folder");
 
D

dw

Frank McCown said:
I found that you can issue a system command that works instead, but it
seems like there should be a Perl function that does the same.

system("chown username.groupname my_folder");

it's in there....
perldoc -f chown
 
F

Frank McCown

This is a reference to the chown function that changes FILE ownership,
not DIRECTORY ownership. I've tried to use the chown function to
modifiy dir ownership, and it fails.
 
N

nobull

This has probably been answered a million times, but I can't seem to
find the answer.

Possibly because the question doesn't exist.
How can I change the owner of a directory using a Perl command? I
know chown can be used with files, but it doesn't appear to work with
directories.

Please produce a minimal but complete set of instuctions to reproduce
the apparance of it not working.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 
D

dw

Frank McCown said:
This is a reference to the chown function that changes FILE ownership,
not DIRECTORY ownership. I've tried to use the chown function to
modifiy dir ownership, and it fails.

It works for me on both files and directories using 5.8 on both Linux and
cygwin.

Only problem I had on Linux was a permission problem when doing it as
someone other than root... doing
chown $owner, -1, $dir or print "unable to change $dir: $!"
gave me "Operation not permitted" as me, but as root, it worked without a
problem.

What error did it give you?

From cygwin:
$ ll
total 0
drwxrwxrwx+ 2 SYSTEM None 0 Dec 2 23:29 dir/
-rw-rw-rw- 1 SYSTEM None 0 Dec 2 23:29 file1
-rw-rw-rw- 1 David None 0 Dec 2 23:29 file2

$ perl -e 'chown ((stat("file2"))[4], -1, "dir", "file1");'

$ ll
total 0
drwxrwxrwx+ 2 David None 0 Dec 2 23:29 dir/
-rw-rw-rw- 1 David None 0 Dec 2 23:29 file1
-rw-rw-rw- 1 David None 0 Dec 2 23:29 file2
 
F

Frank McCown

dw-

Your code snippet worked fine on my system. I ran my original code
this morning and I can't reproduce my original error (yet)... very
frustrating.

I really appreciate your time.


nobull-

You are one witty guy. Why don't you tell the guys at Google that
this newsgroup doesn't "exist", and maybe they'll disable their
software to allow posts to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top