View Single Post
Saturn's Avatar
Posts: 1,648 | Thanked: 2,122 times | Joined on Mar 2007 @ UNKLE's Never Never Land
#2
One way to achive that would be:

Make a sudoers file with this inside:
Code:
user ALL = NOPASSWD: /home/user/.scriptfolder/script.py
(Note it would be safer if the script was placed in /opt/somewhere and owned by root with 744 privileges though)

and place it in /etc/sudoers.d/

in the first line of your py code add this to make it execute directly:
Code:
#!/usr/bin/python2.5
from inside you code to execute the script as root:
Code:
os.system('sudo  /home/user/.scriptfolder/script.py')
Should work..
 

The Following 4 Users Say Thank You to Saturn For This Useful Post: