Running a command as root
I have GKrellm running on my system, and have created two buttons to change the throttling of the CPU. The two buttons execute the commands:
/home/falcon56215/CPUpowersave.sh /home/falcon56215/CPUperformance.sh which are script files that contain the following commands: echo 'powersave' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor echo 'performance' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor The problem is these can be executed as root and work fine, but when I execute as a regular user like GKrellm does, I get: [falcon56215@TuxBox ~]$ ./CPUperformance.sh ./CPUperformance.sh: line 1: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: Permission denied I have tried chmod 4755 CPUperformance.sh, and it is owned by root, but I still get the same error. Any ideas? |
The permissions don't change the effective user ID - the scripts still have the same capabilities you do. You'd either need to make them set UID root (and I'm not even sure you can do that with scripts - on some *nixes you can; some you can't) or you'd need to assign the button action to an 'su -c SCRIPT' or sudo or whatever. And, actually, that'd need to be 'xterm -e su -c' or use something like kdesu or whatever it's called. At least, that's what I'm thinking, though there may be other/better ways or other issues.
|
OK,
I figured it out. I just inserted a command in startup to chmod 777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor and everything works fine. Thanks, Danny |
All times are GMT -5. The time now is 05:25 AM. |