On 19/06/12 22:46, Chris Green wrote:
Is there any way to run a script such that it executes as another user than the person running it?
If you're using the debian/ubuntu/mint flavour of linux, then you can use sudo
use visudo to edit the sudoers file (*)(+) then put in an entry like
desired_user_name ALL = NOPASSWD: /path/to/your/script
NOPASSWD is optional - if it's there, you won't be prompted to enter the password for that user when that script runs. I don't recall what the ALL means.
try man sudoers or man visudo for help, or google it.
Alternatively, you can swicth user with su or sudo. Does that help - can you put it in your script?
HTH Steve
* - don't edit the file directly as there be dragons! + - I think it uses vi editing commands unless you tell it otherwise - check first unless you speak vi!