Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting permissions to a file from linux.

666 views
Skip to first unread message

gaurav kashyap

unread,
Nov 18, 2008, 7:36:47 AM11/18/08
to
Hi all,
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

Chris

unread,
Nov 18, 2008, 8:07:51 AM11/18/08
to

help(os.chmod)
Help on built-in function chmod in module nt:

chmod(...)
chmod(path, mode)

Change the access permissions of a file.

or

os.system('chmod 775 /path/to/filename')

Albert Hopkins

unread,
Nov 18, 2008, 8:10:43 AM11/18/08
to

os.chmod = chmod(...)

Nick Craig-Wood

unread,
Nov 18, 2008, 10:29:57 AM11/18/08
to
Chris <cwi...@gmail.com> wrote:

> On Nov 18, 2:36?pm, gaurav kashyap <gauravkec2...@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 <ni...@craig-wood.com> -- http://www.craig-wood.com/nick

0 new messages