automate sudo
Ihave an extremely small python script(only about 5 or 6 lines) to toggle the system beep. The only problem is that user needs to be root! I want any user to be able to use it, or even for the script to be automatically activated at boot time. Maybe there's a way for init to run it?
In the script, I tried doing 'fakeroot sudo', because that command tends to work in some programs, but it still won't allow(i guess that makes sense since the user is basically altering the way the kernel works).
Like I said, my script is coded in Python - I'm not sure if a workaround would require me to use bash scripting perhaps? (which, by the way, i'm HORRIBLE at bash scripting!!! haha)
Here is the sourcecode below:
import os
import sys
os.system('fakeroot sudo')
if len(sys.argv) < 2:
print "\nToggles system beep\n\nUsage: beep [-on|-off]\n\n"
else:
if sys.argv[-1] == '-on':
os.system('modprobe pcspkr')
elif sys.argv[-1] == '-off':
os.system('rmmod pcspkr')
Let me know if you know of any workarounds!
thanks,
Giuseppe
|