os.remove() permission problem

Christian Heimes lists at cheimes.de
Tue Dec 1 08:12:13 EST 2009


Victor Subervi wrote:
> Well, that's what I've tried. I've loaded the permissions up, 0777, and it
> still throws the same error. I've also tried os.chmod(file, 0777) from the
> script, and I get the same permissions error. I can do all of this from the
> python prompt. I've set the ownership of the file attempting these commands
> to root.root. Nothing works. Please advise.

You have to set the write and execute permssion on *directory*, not on
the file. unlink (aka remove) requires write permission on the directory
in order to remove the file.

It's like in the real world. You may be allowed to modify a document (w
permission on the file) but you may not be allowed to remove it from its
cabinet (w permission on the directory).

Christian



More information about the Python-list mailing list