View Full Version : PyBash
Sandsound
November 5th, 2009, 05:34 PM
Can someone please tell me why this doesn't work :
os.system('gksudo "cp -f /home/sandie/Desktop/folder/* /home/sandie/Desktop"')
I can do this :
os.system("cp -f /home/sandie/Desktop/folder/* /home/sandie/Desktop")
but get a "cp: cannot stat" error when I include gksudo ?
NoaHall
November 5th, 2009, 06:40 PM
Why use gksudo for a cli command?
sisco311
November 5th, 2009, 07:07 PM
os.system("gksudo \"bash -c 'cp -f /source/dir/* /dest/dir'\"")
in karmic you can use pkexec (policykit):
os.system("pkexec cp -f /source/dir/* /dest/dir")
it works much better with cli commands than gksu.
juancarlospaco
November 5th, 2009, 07:11 PM
import os
os.system("gksudo \"xterm -e 'cp -f /source/dir/* /dest/dir'\"")
Sandsound
November 6th, 2009, 12:12 AM
Why use gksudo for a cli command?
It's a Python program with a gui and I don't want the whole program to run as root only the things that require it.
Sandsound
November 6th, 2009, 12:18 AM
os.system("gksudo \"bash -c 'cp -f /source/dir/* /dest/dir'\"")
in karmic you can use pkexec (policykit):
os.system("pkexec cp -f /source/dir/* /dest/dir")
it works much better with cli commands than gksu.
thanks, but I kind'a like the minimalistic way gksudo ask for authorization.
Does pkexec behave like gksudo ? (if i do a gksudo it remember the authorization and the next gksudo will not prompt for password).
Sandsound
November 6th, 2009, 12:22 AM
import os
os.system("gksudo \"xterm -e 'cp -f /source/dir/* /dest/dir'\"")
I did have "import os" but the xterm did the trick.
Thanks :-D
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.