Python Script Cannot Write to Directory

Steven D'Aprano steve at
Wed Aug 4 11:29:37 CEST 2010

On Tue, 03 Aug 2010 21:01:38 -0700, Chris Brauchli wrote:

> Hi,
> I am writing a script that, at one point, copies a file from directory A
> to directory B. Directory B can only be written to by root, but the
> script is always called with sudo, so this shouldn't be an issue, but it
> is. I have tried using shutil.copy() and calling "sudo cp " with
> os.popen to no avail. I cannot get the script to copy a file to
> directory B.
> Any ideas why this is happening? If more information is needed or
> something isn't clear let me know. Thanks for helping.

Without seeing the traceback and the actual line of code that fails, and 
preferably the full set of permissions on the directory, we'd be 
guessing. Now, I love to play "debug the program by making wild guesses" 
with other people's code, but you might not like my suggestions :)


More information about the Python-list mailing list