Python Script Cannot Write to Directory

Chris Brauchli cbrauchli at gmail.com
Wed Aug 4 00:01:38 EDT 2010


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. The strange thing is if I run the python interpreter (as
sudo) and type in shutil.copy it works. It also works if I try to copy
the file to a less protected directory. It only happens when I try to
copy a file to directory B from a python script.

Any ideas why this is happening? If more information is needed or
something isn't clear let me know. Thanks for helping.

Chris



More information about the Python-list mailing list