setting permissions to a file from linux.

Nick Craig-Wood nick at craig-wood.com
Tue Nov 18 10:29:57 EST 2008


Chris <cwitts at gmail.com> wrote:
>  On Nov 18, 2:36?pm, gaurav kashyap <gauravkec2... at gmail.com> wrote:
> > I have a text file in a directory on unix system.
> > Using a python program i want to change that file's permissions.
> > How could this be done.
> >
> > Thanks
> 
>  help(os.chmod)
>  Help on built-in function chmod in module nt:
> 
>  chmod(...)
>      chmod(path, mode)
> 
>      Change the access permissions of a file.

... and just watch out that we usually supply the arguments to chmod
in octal, so you want

os.chmod(0775, "directory")

rather than

os.chmod(775, "directory")

(leading 0 implies octal)

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list