[Melbourne-pm] chowning symlinks in perl?

Daniel Pittman daniel at rimspace.net
Fri Sep 23 07:04:41 PDT 2005


David Dick <david_dick at iprimus.com.au> writes:

You know, it is difficult to follow all this discussion upside down. :)

> yeah, that chowns the file pointed to by the symlink, but what how do i 
> chown the symlink?

So far as I know, changing the ownership of a symbolic link, rather than
what it points to, is a relatively unportable idiom...

Anyway, the system call you want is 'lchown', which does not follow
symbolic links.  I don't know of anything that exports it by default,
but you should be able to call it with the syscall interface or find a
suitable module.

> Alfie John wrote:
>> sorry... forgot you wanted the actual symlink:
>> 
>> my $filename = readlink $symlink;
>> chown $uid, $gid, $filename;
>> 
>> Alfie
>> 
>> On 23/09/2005, at 9:50 PM, Alfie John wrote:
>> 
>>> how about using Perl's chown function?
>>>
>>> perldoc -f chown
>>>
>>> Alfie
>>>
>>> On 23/09/2005, at 8:03 PM, David Dick wrote:
>>>
>>>
>>>> Can anyone figure out how to do chown a symlink in perl? Not the
>>>> referent, but the actual symlink. My best effort so far is
>>>>
>>>> system("chown user:group symlink");
>>>>
>>>> but there might be a better way/module?
>>>>
>>>> uru
>>>> -Dave
>>>> _______________________________________________
>>>> Melbourne-pm mailing list
>>>> Melbourne-pm at pm.org
>>>> http://mail.pm.org/mailman/listinfo/melbourne-pm
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Melbourne-pm mailing list
>>> Melbourne-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/melbourne-pm
>>>
>> 
>> 
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm


More information about the Melbourne-pm mailing list