469,890 Members | 1,901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

change dir owner

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
Jul 19 '05 #1
7 9023
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");
Jul 19 '05 #2
dw
"Frank McCown" <mc*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
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
Jul 19 '05 #3
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's in there....
perldoc -f chown

Jul 19 '05 #4
mc*****@yahoo.com (Frank McCown) wrote in message news:<87**************************@posting.google. com>...
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.
Jul 19 '05 #5
dw
"Frank McCown" <mc*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
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's in there....
perldoc -f chown


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


Jul 19 '05 #6
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.
Jul 19 '05 #7
In a follow-up to someone else, but clearly supposed to be in response
to my post, mc*****@yahoo.com (Frank McCown) wrote:
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.


http://groups.google.com/groups?thre...ing.google.com
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Denis | last post: by
reply views Thread by =?Utf-8?B?TWFydGluIw==?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.