How to start a background script without sudo?

Asked by smurf

I have a Asus EeePc 701 with Ubuntu 9.04, kernel 2.6.29.3 custom. The kernel has a module to detect the eeepc hotkey Fn+Fx, it works well, now I can detect Fn+F2 key to switch on/off the wifi card.
So I wrote a small script that does the switch, it is called /usr/local/bin/wlonoff.sh.
Obviously it has to be run as root because write a system file and invoke ifconfig up/down.

Presently it works because I setted in sudoers that can be run NOPASSWD and when I press Fn+F2 in GConf I made a key that starts another script that inside only has: sudo /usr/local/bin/wlonoff.sh. It works.

But I wonder: is there a way I can start directly the /usr/local/bin/wlonoff.sh script without sudo but with the root privileges?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu sudo Edit question
Assignee:
No assignee Edit question
Solved by:
Micah Gersten
Solved:
Last query:
Last reply:
Revision history for this message
Best Micah Gersten (micahg) said :
#1

You can't do this directly. You could have your script create a file that a crontab entry checks for every minute and runs if that special file exists or has a certain value.

Revision history for this message
smurf (luca-dgh) said :
#2

Thanks Micah Gersten, that solved my question.

Revision history for this message
smurf (luca-dgh) said :
#3

ok, thanks MIcah for the answer, I'll keep my solution working.