[Tutor] Copy file as root
Timo
timovwb at gmail.com
Thu Jun 12 11:38:53 CEST 2008
John Fouhy schreef:
> On 11/06/2008, Timo <timovwb at gmail.com> wrote:
>
>> Hello, I'm writing a program in Python/pyGTK and I need to be root 2
>> times. The first time is to open a file, let's say menu.lst. I use
>> os.system('gksudo gedit /boot/grub/menu.lst'), so that works. But what
>> if I have a copy of the file on my desktop? I use shutil.copyfile() to
>> copy the file from /boot/grub/ to /home/user/Desktop, but ofcourse need
>> to be root to copy it back.
>> So, how can I use shutil.copyfile() with gksudo to ask the password? Or
>> is the another good way to do this in Python?
>>
>
> Presumably you could do os.system('gksudo cp
> /home/user/Desktop/menu.lst /boot/grub') ?
>
>
Yep correct, but this isn't the "Python" way I think. Ah well, I'll use
this as a solution for now and see if I find something else.
More information about the Tutor
mailing list