You are not logged in.
OK I got a little bash script where I type in how many minutes my computer will poweroff.
Normally, it can be ran with regular user even the code contains command "poweroff" which requires root privilegies so, when times up, instead of poweroff, I get message: "poweroff: must be superuser"
Now, I want it to be like, when I run it (./myscript) to require authentication before the script even start like, for example Gparted requires, so if an authentication passes, my scirpt can run and have permission to do whatever it's written in it (in this case, 'poweroff').
Thanks ^_^
Last edited by broi (2012-03-24 23:38:44)
Offline
(From another thread)
# Check for admin rights. If user is not an admin user, exit the script if [ $UID != 0 ] then echo "You need to be root to run this script! Exiting..." exit fi
This snippet checks if you've sudo-ed it (or ran as root). All subsequent commands can be coded without sudo.
Offline
Thank you very much!
Another solution would be executing your script with pkexec [scriptname], so you get GUI authenticaion requirement.
Offline
Or you can invoke D-Bus as regular user to shutdown your computer.
For more information: http://linuxtidbits.wordpress.com/2012/ … mand-line/
Offline
Or you can add poweroff, or your script name to your sudoers file to not need a password.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline